# Quat

Quaternions are efficient and robust mathematical objects for representing rotations! Understanding the details of how a quaterion works is not generally necessary for using them effectively, so don’t worry too much if they seem weird to you. They’re weird to me too.

If you’re interested in learning the details though, 3Blue1Brown and Ben Eater have an excellent interactive lesson about them!

## Instance Fields and Properties

float w | Components of the quaternion equation: w + xi + yj + z*k |

float x | Components of the quaternion equation: w + xi + yj + z*k |

float y | Components of the quaternion equation: w + xi + yj + z*k |

float z | Components of the quaternion equation: w + xi + yj + z*k |

## Instance Methods

Quat | You may want to use static creation methods, like Quat.LookAt, or Quat.Identity instead of this one! Unless you know what you’re doing. |

Inverse | The reverse rotation! If this quat goes from A to B, the inverse will go from B to A. |

Normalize | A normalized quaternion has the same orientation, and a length of 1. |

## Static Fields and Properties

Quat Identity | This is the ‘multiply by one!’ of the quaternion rotation world. It’s basically a default, no rotation quaternion. |

## Static Methods

Difference | This gives a relative rotation between the first and second quaternion rotations. Remember that order is important here! |

FromAngles | Creates a Roll/Pitch/Yaw rotation (applied in that order) from the provided angles in degrees! |

LookAt | Creates a rotation from a resting direction, to a direction indicated by the direction of the two vectors provided to the function! This is a great function for camera style rotation, when you know where a camera is, and where you want to look at. This prevents roll on the Z axis, Up is always (0,1,0). |

LookDir | Creates a rotation from a resting direction, to the given direction! This prevents roll on the Z axis, Up is always (0,1,0) |

Slerp | Spherical Linear intERPolation. Interpolates between two quaternions! Both Quats should be normalized/unit quaternions, or you may get unexpected results. |