Package de.tilman_neumann.jml.quaternion
Class RationalQuaternion
java.lang.Object
de.tilman_neumann.jml.quaternion.RationalQuaternion
public class RationalQuaternion
extends java.lang.Object
Quaternions are an extension of complex numbers to four dimensions defined as Q(i,j,k) = {x + y*i + z*j + w*k : x,y,z,w ∈ R and i^2 = j^2 = k^2 = ijk = -1}.
-
Constructor Summary
Constructors Constructor Description RationalQuaternion(BigRational x, BigRational y, BigRational z, BigRational w) -
Method Summary
Modifier and Type Method Description RationalQuaternionadd(RationalQuaternion b)RationalQuaternionconjugate()booleanequals(java.lang.Object o)BigRationalgetW()BigRationalgetX()BigRationalgetY()BigRationalgetZ()inthashCode()RationalQuaternioninverse()The inverse of a quaternion q is the conjugate of q divided coefficient-wise by the norm of q.booleanisUnit()booleanisZero()RationalQuaternionleftDivide(RationalQuaternion b)"left-divide" this by b.RationalQuaternionmultiply(BigRational b)RationalQuaternionmultiply(RationalQuaternion b)RationalQuaternionmultiply(java.math.BigInteger b)RationalQuaternionnegate()BigRationalnorm()RationalQuaternionnormalize()RationalQuaternionrightDivide(RationalQuaternion b)"right-divide" this by b.RationalQuaternionsquare()RationalQuaternionsubtract(RationalQuaternion b)java.lang.StringtoString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
RationalQuaternion
-
-
Method Details
-
getX
-
getY
-
getZ
-
getW
-
conjugate
-
negate
-
normalize
-
norm
- Returns:
- the norm of this
-
isZero
public boolean isZero() -
isUnit
public boolean isUnit()- Returns:
- true if this is a unit
-
add
-
subtract
-
multiply
-
multiply
-
multiply
-
square
-
inverse
The inverse of a quaternion q is the conjugate of q divided coefficient-wise by the norm of q.- Returns:
- the inverse of this
-
leftDivide
"left-divide" this by b. In quaternions, there are two division algorithms, because multiplication is not commutative. The left-division variant computes a/b = inverse(b)*a = conjugate(b)*a / N(b). Its resulting quotient is apt for the right term in a complementary test multiplication. The division in rational coefficients is exact, i.e. there is no remainder.- Parameters:
b-- Returns:
- left division quotient
-
rightDivide
"right-divide" this by b. In quaternions, there are two division algorithms, because multiplication is not commutative. The right-division variant computes a/b = a*inverse(b) = a*conjugate(b) / N(b). Its resulting quotient is apt for the left> term in a complementary test multiplication. The division in rational coefficients is exact, i.e. there is no remainder.- Parameters:
b-- Returns:
- right division quotient
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-