Class | Eymiha::Quaternion |
In: |
lib/eymiha/math3/quaternion.rb
|
Parent: | Object |
Quaternion instances represents Quaternions, complex numbers with one real part and three imaginary parts. While the math is a bit obscure, they can be used to manipulate 3D rotations without "gimbal lock", the problem of coincident viewing angle alignment problems at the boundaries, for example, where the difference between the x and y coordinates of the viewing vector are zero (ie. looking straight up or straight down.)
Interestingly, Quaternions were first conceptualized by Hamilton in 1843, well before the widespread use of vector notation. While mostly put on the shelf, they still solve certain problems elegantly, and in some cases more quickly than matrix-based 3D calulations.
The quaternion‘s real part is accessed through the real instance variable, the three complex parts as the quaternion‘s "axis" vector, a Point3.
axis | [RW] | complex axis vector part reader and writer |
real | [RW] | real part reader and writer |
Creates and returns a Quaternion instance. Sets the coordinates values using the set method.
Returns true if the parts of the instance are equal to the parts of the given quaternion.
Returns a new Quaternion instance whose parts are the original instance‘s with the given amounts added:
Returns true if the parts of the instance are approximately equal to the parts of the given quaternion, each part less than a distance epsilon from the target.
Returns a new Quaternion instance whose parts are the original instance‘s divided by the given amounts:
Returns a new Quaternion instance whose parts are the original instance‘s multiplied by the given amounts:
Returns a copy of a Quaternion with the given parts:
Returns a new Quaternion instance whose parts are the original instance‘s multiplied by the scalar:
Sets the axis and real values of the instance. When
The modified instance is returned.
Returns a new Quaternion instance whose parts are the original instance‘s with the given amounts subtracted: