|
3rd Eye Scene C#
3rd Eye Scene C# documentation
|
A quaternion implementation for applying 3D rotations. More...
Public Member Functions | |
| Quaternion (float x, float y, float z, float w) | |
| Initialise a quaternion with the given component values. | |
| Quaternion (Vector3 axis, float angle) | |
| Initialise a quaternion using an axis and an angle. | |
| void | SetFromTo (Vector3 from, Vector3 to) |
| Initialise this quaternion as the rotation between from and to . | |
| void | GetAxisAngle (ref Vector3 axis, ref float angle) |
| Converts this quaternion into a axis of rotation and the rotation angle around that axis (radians). | |
| void | SetAxisAngle (Vector3 axis, float angle) |
| Sets this quaternion from an axis of rotation and the angle of rotation about that axis (radians). | |
| void | Invert () |
| Inverts this quaternion so that it expresses the counter rotation to its current value. | |
| void | Conjugate () |
| Sets this quaternion to its conjugate. | |
| float | Normalise (float epsilon=Epsilon) |
| Attempts to normalise this quaternion. | |
| float | Dot (Quaternion other) |
Calculates the dot product of
this
| |
| Vector3 | Transform (Vector3 v) |
| Transforms v by this quaternion rotation. | |
| void | Multiply (float scalar) |
| Multiply all components of this quaternion by a scalar. | |
| override bool | Equals (object obj) |
| Compare two quaternions for precise numeric equality. | |
| override int | GetHashCode () |
| Generates a simple hash code for the quaternion. | |
Static Public Member Functions | |
| static Quaternion | FromTo (Vector3 from, Vector3 to) |
| Static method for constructing a quaternion as a rotation between from and to . | |
| static Quaternion | AxisAngle (Vector3 axis, float angle) |
| Creates a quaternion from an axis an angle. | |
| static Quaternion | Slerp (Quaternion from, Quaternion to, float t) |
| Performs a spherical linear interpolation of one quaternion to another. | |
| static bool | operator== (Quaternion a, Quaternion b) |
| Compare two quaternions for precise numeric equality. | |
| static bool | operator!= (Quaternion a, Quaternion b) |
| Compare two quaternions for inequality using precise numeric equality. | |
| static Quaternion | operator* (Quaternion a, Quaternion b) |
| Transform (rotate) one quaternion by another. | |
| static Vector3 | operator* (Quaternion q, Vector3 v) |
| Transform (rotate) a vector by a quaternion. | |
| static Quaternion | operator* (Quaternion q, float s) |
| Multiply a quaternion by a scalar. | |
| static Quaternion | operator* (float s, Quaternion q) |
| Multiply a quaternion by a scalar. | |
| static Quaternion | operator/ (Quaternion q, float s) |
| Divide a quaternion by a scalar. | |
Public Attributes | |
| const float | Epsilon = 1e-6f |
| Default epsilon value used in various calculations. | |
Static Public Attributes | |
| static Quaternion | Identity = new Quaternion { X = 0, Y = 0, Z = 0, W = 1 } |
| The identity quaternion (0, 0, 0, 1). | |
| static Quaternion | Zero = new Quaternion { X = 0, Y = 0, Z = 0, W = 0 } |
| A zero quaternion (0, 0, 0, 0). | |
Properties | |
| float | X [get, set] |
| The quaternion X component. | |
| float | Y [get, set] |
| The quaternion Y component. | |
| float | Z [get, set] |
| The quaternion Z component. | |
| float | W [get, set] |
| The quaternion W component. | |
| float | this[int index] [get, set] |
| Indexing accessor. | |
| bool | IsZero [get] |
| Is this quaternion exactly zero (0, 0, 0, 0)? | |
| bool | IsIdentity [get] |
| Is this quaternion exactly identity (0, 0, 0, 1)? | |
| float | Magnitude [get] |
| Returns the magnitude of this quaternion. | |
| float | MagnitudeSquared [get] |
| Returns the magnitude squared of this quaternion. | |
| Quaternion | Inverse [get] |
| Calculates and returns the inverse, or counter rotation, of this quaternion. | |
| Quaternion | Conjugated [get] |
| Calculates and returns the conjugate of this quaternion. | |
| Quaternion | normalised [get] |
| Returns a normalised copy of this quaternion. | |
A quaternion implementation for applying 3D rotations.
See Wikipedia or Wolfram MathWorld for technical details on quaternions.
Note that all angles expressed by this class are in radians.
| Tes::Maths::Quaternion::Quaternion | ( | float | x, |
| float | y, | ||
| float | z, | ||
| float | w | ||
| ) | [inline] |
Initialise a quaternion with the given component values.
| x | X component value. |
| y | Y component value. |
| z | Z component value. |
| w | W component value. |
| Tes::Maths::Quaternion::Quaternion | ( | Vector3 | axis, |
| float | angle | ||
| ) | [inline] |
Initialise a quaternion using an axis and an angle.
| axis | The quaternion rotation axis. Must be a unity vector for well defined behaviour. |
| angle | The rotation angle around axis (radians). |
| static Quaternion Tes::Maths::Quaternion::AxisAngle | ( | Vector3 | axis, |
| float | angle | ||
| ) | [inline, static] |
Creates a quaternion from an axis an angle.
This provides a static alternative to SetAxisAngle(Vector3, float).
| axis | The axis of rotation. Must be a unit vector. |
| angle | The rotation angle around axis (radians). |
| void Tes::Maths::Quaternion::Conjugate | ( | ) | [inline] |
Sets this quaternion to its conjugate.
The conjugate is the same quaternion with x, y, z values negated, but w remains as is.
| float Tes::Maths::Quaternion::Dot | ( | Quaternion | other | ) | [inline] |
Calculates the dot product of
this
and other .
| override bool Tes::Maths::Quaternion::Equals | ( | object | obj | ) | [inline] |
Compare two quaternions for precise numeric equality.
| obj | The quaternion to compare to. |
| InvalidCastException | When obj is not a Quaternion. |
| static Quaternion Tes::Maths::Quaternion::FromTo | ( | Vector3 | from, |
| Vector3 | to | ||
| ) | [inline, static] |
Static method for constructing a quaternion as a rotation between from and to .
| from | The vector to rotate from. Should ideally be normalised. |
| to | The vector to rotate to. Should ideally be normalised. |
| void Tes::Maths::Quaternion::GetAxisAngle | ( | ref Vector3 | axis, |
| ref float | angle | ||
| ) | [inline] |
Converts this quaternion into a axis of rotation and the rotation angle around that axis (radians).
| angle | Set to the rotation angle (radians). Zero if this quaternion is identity. |
| axis | Set to the axis of rotation. Set to (0, 0, 1) if this quaternion is identity or near zero length. |
| override int Tes::Maths::Quaternion::GetHashCode | ( | ) | [inline] |
Generates a simple hash code for the quaternion.
Not a very good hash.
| void Tes::Maths::Quaternion::Multiply | ( | float | scalar | ) | [inline] |
Multiply all components of this quaternion by a scalar.
Generally not a very useful operation for a quaternion as quaternions should stay normalised.
| scalar | The scalar to multiply the vector components by. |
| float Tes::Maths::Quaternion::Normalise | ( | float | epsilon = Epsilon | ) | [inline] |
Attempts to normalise this quaternion.
Normalisation fails if the length of this quaternion is less than or equal to epsilon . In this case, the quaternion becomes identity.
| static bool Tes::Maths::Quaternion::operator!= | ( | Quaternion | a, |
| Quaternion | b | ||
| ) | [inline, static] |
Compare two quaternions for inequality using precise numeric equality.
| a | A quaternion to compare. |
| b | A quaternion to compare. |
| static Vector3 Tes::Maths::Quaternion::operator* | ( | Quaternion | q, |
| Vector3 | v | ||
| ) | [inline, static] |
Transform (rotate) a vector by a quaternion.
| q | The quaternion to rotate by. |
| v | The vector to rotate. |
| static Quaternion Tes::Maths::Quaternion::operator* | ( | float | s, |
| Quaternion | q | ||
| ) | [inline, static] |
Multiply a quaternion by a scalar.
Not a very useful operation for a quaternion as they should stay normalised. Provided for completeness.
| s | The scalar to multiply by. |
| q | The quaternion to operate on. |
| static Quaternion Tes::Maths::Quaternion::operator* | ( | Quaternion | a, |
| Quaternion | b | ||
| ) | [inline, static] |
Transform (rotate) one quaternion by another.
The resulting quaternion represents a combined rotation, applying b then a .
| a | The quaternion to rotate by. |
| b | The quaternion to rotate |
| static Quaternion Tes::Maths::Quaternion::operator* | ( | Quaternion | q, |
| float | s | ||
| ) | [inline, static] |
Multiply a quaternion by a scalar.
Not a very useful operation for a quaternion as they should stay normalised. Provided for completeness.
| q | The quaternion to operate on. |
| s | The scalar to multiply by. |
| static Quaternion Tes::Maths::Quaternion::operator/ | ( | Quaternion | q, |
| float | s | ||
| ) | [inline, static] |
Divide a quaternion by a scalar.
Not a very useful operation for a quaternion as they should stay normalised. Provided for completeness.
| q | The quaternion to operate on. |
| s | The scalar to divide by. |
| static bool Tes::Maths::Quaternion::operator== | ( | Quaternion | a, |
| Quaternion | b | ||
| ) | [inline, static] |
Compare two quaternions for precise numeric equality.
| a | A quaternion to compare. |
| b | A quaternion to compare. |
| void Tes::Maths::Quaternion::SetAxisAngle | ( | Vector3 | axis, |
| float | angle | ||
| ) | [inline] |
Sets this quaternion from an axis of rotation and the angle of rotation about that axis (radians).
| axis | The axis of rotation. Must be a unit vector. |
| angle | The rotation angle around axis (radians). |
Initialise this quaternion as the rotation between from and to .
| from | The vector to rotate from. Should ideally be normalised. |
| to | The vector to rotate to. Should ideally be normalised. |
| static Quaternion Tes::Maths::Quaternion::Slerp | ( | Quaternion | from, |
| Quaternion | to, | ||
| float | t | ||
| ) | [inline, static] |
Performs a spherical linear interpolation of one quaternion to another.
This results in a quaternion which rotates partway between from and to .
This is an ambiguity in rotation when from and to are exactly opposed and the resulting quaternion is not well defined.
| from | The quaternion rotation to interpolate from. |
| to | The quaternion rotation to interpolate to. |
| t | The interpolation "time", [0, 1]. Zero selects from while one selects to . |
Transforms v by this quaternion rotation.
The transformation signifies a rotation of v by this quaternion.
Quaternion Tes::Maths::Quaternion::Conjugated [get] |
Calculates and returns the conjugate of this quaternion.
The conjugate is the same quaternion with x, y, z values negated, but w remains as is.
Quaternion Tes::Maths::Quaternion::Inverse [get] |
Calculates and returns the inverse, or counter rotation, of this quaternion.
bool Tes::Maths::Quaternion::IsIdentity [get] |
Is this quaternion exactly identity (0, 0, 0, 1)?
bool Tes::Maths::Quaternion::IsZero [get] |
Is this quaternion exactly zero (0, 0, 0, 0)?
Quaternion Tes::Maths::Quaternion::normalised [get] |
Returns a normalised copy of this quaternion.
Normalisation fails if the length of this quaternion is less than or equal to epsilon.
float Tes::Maths::Quaternion::this[int index] [get, set] |
Indexing accessor.
Indexes X, Y, Z, W across the range [0, 3].
| index | The component index [0, 3]. |
| IndexOutOfRangeException | Thrown when index is out of range. |