# quaternion¶

`quaternion` is used to represent rotations.

### Properties¶

#### quaternion identity¶

A quaternion with the magnitude of zero

#### float3 eulerAngles¶

Returns the euler angle representation of the rotation.

#### number x¶

The x-coordinate of the quaternion

#### number y¶

The y-coordinate of the quaternion

#### number z¶

The z-coordinate of the quaternion

#### number w¶

The w-coordinate of the quaternion

### Functions¶

#### quaternion quaternion.New(number x, number y, number z, number w)¶

Constructs a new quaternion using the given `x`, `y`,`z` and `w` components.

#### number quaternion.Angle(quaternion a, quaternion b)¶

Returns the angle in degrees between two rotations `a` and `b`.

#### quaternion quaternion.AngleAxis(number angle, float3 axis)¶

Creates a rotation which rotates `angle` degrees around `axis`

#### number quaternion.Dot(float4 a, float4 b)¶

Returns dot Product of two rotations.

#### quaternion quaternion.Euler(number x, number y, number z)¶

Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis; applied in that order.

#### quaternion quaternion.FromToRotation(float3 fromDirection, float3 toDirection)¶

Creates a rotation which rotates from `fromDirection` to `toDirection`.

#### quaternion quaternion.Lerp(quaternion a, quaternion b, number t)¶

Linearly interpolates between two points. Interpolates between the points `a` and `b` by `t`. The parameter `t` is clamped to the range [0, 1].
• `a` Start value, returned when t = 0.
• `b` End value, returned when t = 1.
• `t` Interpolation ratio.

#### quaternion quaternion.LookRotation(float3 forward, float3 upwards)¶

Creates a rotation with the specified `forward` and `upwards` directions. Z axis will be aligned with `forward`, X axis aligned with cross product between `forward` and `upwards`, and Y axis aligned with cross product between Z and X.
• `forward` The direction to look in.
• `upwards` The vector that defines in which direction up is.

#### quaternion quaternion.RotateTowards(quaternion from, quaternion to, number maxDegreesDelta)¶

Rotates a rotation from towards to. The `from` quaternion is rotated towards `to` by an angular step of `maxDegreesDelta` (but note that the rotation will not overshoot). Negative values of `maxDegreesDelta` will move away from `to` until the rotation is exactly the opposite direction.

#### quaternion quaternion.Slerp(quaternion a, quaternion b, number t)¶

ReturnsA quaternion spherically interpolated between quaternions a and b.
Spherically interpolates between quaternions `a` and `b` by ratio `t`. The parameter `t` is clamped to the range [0, 1].
• `a` Start value, returned when t = 0.
• `b` End value, returned when t = 1.
• `t` Interpolation ratio.

#### quaternion Clone()¶

Returns a deep copy of this quaternion.

#### quaternion Inverse()¶

Returns the Inverse of rotation.

#### void Set(number x, number y, number z, number w)¶

Set `x`, `y`, `z` and `w` components of an existing quaternion.

#### quaternion Normalize()¶

Returns this quaternion with a magnitude of 1

#### void SetNormalize()¶

Makes this quaternion with a magnitude of 1.

#### quaternion ToAngleAxis()¶

Converts a rotation to angle-axis representation