jsci.maths
Class Quaternion
- java.lang.Object
-
- jsci.maths.Quaternion
-
- All Implemented Interfaces:
- java.io.Serializable, Algebra.Member, BanachSpace.Member, CStarAlgebra.Member, Module.Member, VectorSpace.Member, Field.Member, Ring.Member, AbelianGroup.Member, Member
public final class Quaternion extends java.lang.Object implements Field.Member, CStarAlgebra.Member
The Quaternion class encapsulates quaternions.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static QuaternionIstatic QuaternionJstatic QuaternionKstatic QuaternionONE
-
Constructor Summary
Constructors Constructor and Description Quaternion(double real, Double3Vector imag)Constructs a quaternion.Quaternion(double q0, double q1, double q2, double q3)Constructs the quaternion q0+iq1+jq2+kq3.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description AbelianGroup.Memberadd(AbelianGroup.Member x)Returns the addition of this number and another.Quaternionadd(Quaternion q)Returns the addition of this quaternion and another.QuaternionaddImag(Double3Vector imag)Returns the addition of this quaternion with an imaginary part.QuaternionaddReal(double real)Returns the addition of this quaternion with a real part.Quaternionconjugate()Returns the conjugate of this quaternion.static Quaternioncos(Quaternion q)static Quaternioncosh(Quaternion q)Quaterniondivide(double x)Returns the division of this quaternion by a scalar.Field.Memberdivide(Field.Member x)Returns the division of this number and another.Quaterniondivide(Quaternion q)Returns the division of this quaternion by another.booleanequals(java.lang.Object obj)Compares two quaternions for equality.static Quaternionexp(Quaternion q)java.lang.ObjectgetSet()inthashCode()Returns a hashcode for this quaternion.Double3Vectorimag()Returns the imaginary part of this quaternion.Field.Memberinverse()Returns the inverse of this quaternion.CStarAlgebra.Memberinvolution()Returns the involution of this quaternion.booleanisInfinite()Returns true if either the real or imaginary part is infinite.booleanisNaN()Returns true if either the real or imaginary part is NaN.static Quaternionlog(Quaternion q)Quaternionmultiply(double x)Returns the multiplication of this quaternion by a scalar.Quaternionmultiply(Quaternion q)Returns the multiplication of this quaternion and another.Ring.Membermultiply(Ring.Member x)Returns the multiplication of this number and another.AbelianGroup.Membernegate()Returns the negative of this quaternion.doublenorm()Returns the l2-norm (magnitude), which is also the C* norm.Quaternionnormalize()doublereal()Returns the real part of this quaternion.static Quaternionrotation(AbstractDoubleSquareMatrix m)Constructs a quaternion representing a rotation matrix.VectorSpace.MemberscalarDivide(Field.Member x)Returns the division of this number by a real scalar.Module.MemberscalarMultiply(Ring.Member x)Returns the multiplication of this number by a real scalar.static Quaternionsin(Quaternion q)static Quaternionsinh(Quaternion q)AbelianGroup.Membersubtract(AbelianGroup.Member x)Returns the subtraction of this number and another.Quaternionsubtract(Quaternion q)Returns the subtraction of this quaternion by another.QuaternionsubtractImag(Double3Vector imag)Returns the subtraction of this quaternion by an imaginary part.QuaternionsubtractReal(double real)Returns the subtraction of this quaternion by a real part.doublesumSquares()Returns the sum of the squares of the components.static Quaterniontan(Quaternion q)static Quaterniontanh(Quaternion q)AbstractDoubleSquareMatrixtoRotationMatrix()Returns a 3D rotation matrix representing this quaternion.java.lang.StringtoString()Returns a string representing the value of this quaternion.
-
-
-
Field Detail
-
ONE
public static final Quaternion ONE
-
I
public static final Quaternion I
-
J
public static final Quaternion J
-
K
public static final Quaternion K
-
-
Constructor Detail
-
Quaternion
public Quaternion(double real, Double3Vector imag)Constructs a quaternion.
-
Quaternion
public Quaternion(double q0, double q1, double q2, double q3)Constructs the quaternion q0+iq1+jq2+kq3.
-
-
Method Detail
-
rotation
public static Quaternion rotation(AbstractDoubleSquareMatrix m)
Constructs a quaternion representing a rotation matrix. Note: if the matrix is not orthogonal then the quaternion will not have unit norm. Note: unit quaternions are a double cover of SO(3).- Parameters:
m- a rotation matrix
-
toRotationMatrix
public AbstractDoubleSquareMatrix toRotationMatrix()
Returns a 3D rotation matrix representing this quaternion. Note: if this quaternion does not have unit norm then the matrix will not be orthogonal.
-
equals
public boolean equals(java.lang.Object obj)
Compares two quaternions for equality.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- a quaternion
-
toString
public java.lang.String toString()
Returns a string representing the value of this quaternion.- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
Returns a hashcode for this quaternion.- Overrides:
hashCodein classjava.lang.Object
-
isNaN
public boolean isNaN()
Returns true if either the real or imaginary part is NaN.
-
isInfinite
public boolean isInfinite()
Returns true if either the real or imaginary part is infinite.
-
real
public double real()
Returns the real part of this quaternion.
-
imag
public Double3Vector imag()
Returns the imaginary part of this quaternion.
-
norm
public double norm()
Returns the l2-norm (magnitude), which is also the C* norm.- Specified by:
normin interfaceBanachSpace.Member
-
sumSquares
public double sumSquares()
Returns the sum of the squares of the components.
-
negate
public AbelianGroup.Member negate()
Returns the negative of this quaternion.- Specified by:
negatein interfaceAbelianGroup.Member
-
inverse
public Field.Member inverse()
Returns the inverse of this quaternion.- Specified by:
inversein interfaceField.Member
-
involution
public CStarAlgebra.Member involution()
Returns the involution of this quaternion.- Specified by:
involutionin interfaceCStarAlgebra.Member
-
conjugate
public Quaternion conjugate()
Returns the conjugate of this quaternion.
-
add
public AbelianGroup.Member add(AbelianGroup.Member x)
Returns the addition of this number and another.- Specified by:
addin interfaceAbelianGroup.Member- Parameters:
x- a group member
-
add
public Quaternion add(Quaternion q)
Returns the addition of this quaternion and another.- Parameters:
q- a quaternion
-
addReal
public Quaternion addReal(double real)
Returns the addition of this quaternion with a real part.- Parameters:
real- a real part
-
addImag
public Quaternion addImag(Double3Vector imag)
Returns the addition of this quaternion with an imaginary part.- Parameters:
imag- an imaginary part
-
subtract
public AbelianGroup.Member subtract(AbelianGroup.Member x)
Returns the subtraction of this number and another.- Specified by:
subtractin interfaceAbelianGroup.Member- Parameters:
x- a group member
-
subtract
public Quaternion subtract(Quaternion q)
Returns the subtraction of this quaternion by another.- Parameters:
q- a quaternion
-
subtractReal
public Quaternion subtractReal(double real)
Returns the subtraction of this quaternion by a real part.- Parameters:
real- a real part
-
subtractImag
public Quaternion subtractImag(Double3Vector imag)
Returns the subtraction of this quaternion by an imaginary part.- Parameters:
imag- an imaginary part
-
scalarMultiply
public Module.Member scalarMultiply(Ring.Member x)
Returns the multiplication of this number by a real scalar.- Specified by:
scalarMultiplyin interfaceModule.Member- Parameters:
x- a ring member
-
multiply
public Ring.Member multiply(Ring.Member x)
Returns the multiplication of this number and another.- Specified by:
multiplyin interfaceRing.Member- Parameters:
x- a ring member
-
multiply
public Quaternion multiply(Quaternion q)
Returns the multiplication of this quaternion and another.- Parameters:
q- a quaternion
-
multiply
public Quaternion multiply(double x)
Returns the multiplication of this quaternion by a scalar.- Parameters:
x- a real number
-
scalarDivide
public VectorSpace.Member scalarDivide(Field.Member x)
Returns the division of this number by a real scalar.- Specified by:
scalarDividein interfaceVectorSpace.Member- Parameters:
x- a field member
-
divide
public Field.Member divide(Field.Member x)
Returns the division of this number and another.- Specified by:
dividein interfaceField.Member- Parameters:
x- a field member
-
divide
public Quaternion divide(Quaternion q)
Returns the division of this quaternion by another.- Parameters:
q- a quaternion- Throws:
java.lang.ArithmeticException- If divide by zero.
-
divide
public Quaternion divide(double x)
Returns the division of this quaternion by a scalar.- Parameters:
x- a real number- Throws:
java.lang.ArithmeticException- If divide by zero.
-
normalize
public Quaternion normalize()
-
exp
public static Quaternion exp(Quaternion q)
-
log
public static Quaternion log(Quaternion q)
-
sin
public static Quaternion sin(Quaternion q)
-
cos
public static Quaternion cos(Quaternion q)
-
tan
public static Quaternion tan(Quaternion q)
-
sinh
public static Quaternion sinh(Quaternion q)
-
cosh
public static Quaternion cosh(Quaternion q)
-
tanh
public static Quaternion tanh(Quaternion q)
-
-
DMelt 3.0 © DataMelt by jWork.ORG