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 RationalQuaternion
add(RationalQuaternion b)
RationalQuaternion
conjugate()
boolean
equals(java.lang.Object o)
BigRational
getW()
BigRational
getX()
BigRational
getY()
BigRational
getZ()
int
hashCode()
RationalQuaternion
inverse()
The inverse of a quaternion q is the conjugate of q divided coefficient-wise by the norm of q.boolean
isUnit()
boolean
isZero()
RationalQuaternion
leftDivide(RationalQuaternion b)
"left-divide" this by b.RationalQuaternion
multiply(BigRational b)
RationalQuaternion
multiply(RationalQuaternion b)
RationalQuaternion
multiply(java.math.BigInteger b)
RationalQuaternion
negate()
BigRational
norm()
RationalQuaternion
normalize()
RationalQuaternion
rightDivide(RationalQuaternion b)
"right-divide" this by b.RationalQuaternion
square()
RationalQuaternion
subtract(RationalQuaternion b)
java.lang.String
toString()
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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-