Class Quaternion2
java.lang.Object
edu.nps.moves.legacy.math.Quaternion2
The Quaternion2 class executes quaternion operations.
- Author:
- Ildeniz Duman
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorQuaternion2
(String myName) Default constructorQuaternion2
(String myName, double ww, double xx, double yy, double zz) Default constructor -
Method Summary
Modifier and TypeMethodDescriptionadd
(Quaternion2 QUAT) Adds two quaternionsdouble
dotProduct
(Quaternion2 QUAT5) Finds the dot product of two quaternionsdouble
getW()
Returns the w value of quaternion.double
getX()
Returns the x value of quaternion.double
getY()
Returns the y value of quaternion.double
getZ()
Returns the z value of quaternion.invert()
Finds the inverse (conjugate) of a quaternionstatic void
Main method for testingmultiply
(double NUM) Multiplies this quaternion with a scalarmultiply
(Quaternion2 QUAT) Multiplies two quaternionsvoid
Normalizes the quaternion modifies the current quaternionrotate
(Quaternion2 QUAT4) Rotates a vector by quaternionsvoid
setQuaternion2
(double ww, double xx, double yy, double zz) Sets the quaternion valuessubstract
(Quaternion2 QUAT) Substracts two quaternionsCalculates the axis angles of quaternion for drawing, results must be used in glRotatef() by using get() functionstoBody
(Quaternion2 QUAT) Converts to body coordinatesConverts a quaternion into Euler angles Warning : This conversion is inherently ill-definedfloat[]
toFloat()
Converts quaternion's values into floatCalculates the quaternion value of three rotations Current object is a 3D vector with rotation angles in quaternion formtoString()
Overrides the toString method
-
Constructor Details
-
Quaternion2
Default constructor- Parameters:
myName
- Name of the quaternionww
- w value of the quaternionxx
- x value of the quaternionyy
- y value of the quaternionzz
- z value of the quaternion
-
Quaternion2
-
Quaternion2
public Quaternion2()Default constructor
-
-
Method Details
-
setQuaternion2
public void setQuaternion2(double ww, double xx, double yy, double zz) Sets the quaternion values- Parameters:
ww
- w value of the quaternionxx
- x value of the quaternionyy
- y value of the quaternionzz
- z value of the quaternion
-
getW
public double getW()Returns the w value of quaternion. -
getX
public double getX()Returns the x value of quaternion. -
getY
public double getY()Returns the y value of quaternion. -
getZ
public double getZ()Returns the z value of quaternion. -
multiply
Multiplies two quaternions- Parameters:
QUAT
- second quaternion- Returns:
- new Quaternion2
-
multiply
Multiplies this quaternion with a scalar- Parameters:
NUM
- is a scalar- Returns:
- modified Quaternion2
-
add
Adds two quaternions- Parameters:
QUAT
- is a quaternion to add- Returns:
- new Quaternion2
-
substract
Substracts two quaternions- Parameters:
QUAT
- is a quaternion to substract- Returns:
- new Quaternion2
-
invert
-
rotate
Rotates a vector by quaternions- Parameters:
QUAT4
- a vector in quaternion form- Returns:
- Rotated vector in quaternion form
-
toBody
Converts to body coordinates- Parameters:
QUAT
- a vector in quaternion form to convert to body coordinates- Returns:
- Converted vector in quaternion form
-
dotProduct
Finds the dot product of two quaternions- Parameters:
QUAT5
- a quaternion- Returns:
- Dot product value
-
normalize
public void normalize()Normalizes the quaternion modifies the current quaternion -
toAxisAngles
Calculates the axis angles of quaternion for drawing, results must be used in glRotatef() by using get() functions- Returns:
- Result in quaternion form
-
toQuaternion2
Calculates the quaternion value of three rotations Current object is a 3D vector with rotation angles in quaternion form- Returns:
- new Quaternion2
-
toEulerAngles
Converts a quaternion into Euler angles Warning : This conversion is inherently ill-defined- Returns:
- new Quaternion2
-
toString
-
toFloat
public float[] toFloat()Converts quaternion's values into float- Returns:
- Float []
-
main
Main method for testing
-