org.jscience.mathematics.algebraic.numbers
Class Quaternion

java.lang.Object
  extended by java.lang.Number
      extended by org.jscience.mathematics.algebraic.numbers.Quaternion
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Algebra.Member, BanachSpace.Member, CStarAlgebra.Member, Field.Member, Ring.Member, AbelianGroup.Member, Module.Member, VectorSpace.Member, Member

public final class Quaternion
extends java.lang.Number
implements java.lang.Cloneable, java.io.Serializable, Field.Member, CStarAlgebra.Member

The Quaternion class encapsulates quaternions.

See Also:
Serialized Form

Field Summary
static Quaternion I
           
static Quaternion J
           
static Quaternion K
           
static double MAX_IMAGINARY_VALUE
           
static double MAX_REAL_VALUE
           
static double MIN_IMAGINARY_VALUE
           
static double MIN_REAL_VALUE
           
static double NaN
           
static double NEGATIVE_IMAGINARY_INFINITY
           
static double NEGATIVE_REAL_INFINITY
           
static Quaternion ONE
           
static double POSITIVE_IMAGINARY_INFINITY
           
static double POSITIVE_REAL_INFINITY
           
static java.lang.Class TYPE
           
static Quaternion ZERO
           
 
Constructor Summary
Quaternion(double real, Double3Vector imag)
          Constructs a quaternion.
Quaternion(double q0, double q1, double q2, double q3)
          Constructs the quaternion q0+iq1+jq2+kq3.
Quaternion(Quaternion quat)
          Constructs a quaternion.
 
Method Summary
 AbelianGroup.Member add(AbelianGroup.Member x)
          Returns the addition of this number and another.
 Quaternion add(Quaternion q)
          Returns the addition of this quaternion and another.
 Quaternion addImag(Double3Vector imag)
          Returns the addition of this quaternion with an imaginary part.
 Quaternion addReal(double real)
          Returns the addition of this quaternion with a real part.
 java.lang.Object clone()
           
 Quaternion conjugate()
          Returns the conjugate of this quaternion.
 Quaternion divide(double x)
          Returns the division of this quaternion by a scalar.
 Field.Member divide(Field.Member x)
          Returns the division of this number and another.
 Quaternion divide(Quaternion q)
          Returns the division of this quaternion by another.
 double doubleValue()
           
 boolean equals(java.lang.Object obj)
          Compares two quaternions for equality.
 float floatValue()
           
 int hashCode()
          Returns a hashcode for this quaternion.
 Double3Vector imag()
          Returns the imaginary part of this quaternion.
 int intValue()
           
 Field.Member inverse()
          Returns the inverse of this quaternion.
 CStarAlgebra.Member involution()
          Returns the involution of this quaternion.
 boolean isInfinite()
          Returns true if either the real or imaginary part is infinite.
 boolean isNaN()
          Returns true if either the real or imaginary part is NaN.
 long longValue()
           
 Quaternion multiply(double x)
          Returns the multiplication of this quaternion by a scalar.
 Quaternion multiply(Quaternion q)
          Returns the multiplication of this quaternion and another.
 Ring.Member multiply(Ring.Member x)
          Returns the multiplication of this number and another.
 AbelianGroup.Member negate()
          Returns the negative of this quaternion.
 double norm()
          Returns the l2-norm (magnitude), which is also the C* norm.
 double real()
          Returns the real part of this quaternion.
 VectorSpace.Member scalarDivide(Field.Member x)
          Returns the division of this number by a real scalar.
 Module.Member scalarMultiply(Ring.Member x)
          Returns the multiplication of this number by a real scalar.
 AbelianGroup.Member subtract(AbelianGroup.Member x)
          Returns the subtraction of this number and another.
 Quaternion subtract(Quaternion q)
          Returns the subtraction of this quaternion by another.
 Quaternion subtractImag(Double3Vector imag)
          Returns the subtraction of this quaternion by an imaginary part.
 Quaternion subtractReal(double real)
          Returns the subtraction of this quaternion by a real part.
 double sumSquares()
          Returns the sum of the squares of the components.
 java.lang.String toString()
          Returns a string representing the value of this quaternion.
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final Quaternion ZERO

ONE

public static final Quaternion ONE

I

public static final Quaternion I

J

public static final Quaternion J

K

public static final Quaternion K

MAX_REAL_VALUE

public static final double MAX_REAL_VALUE
See Also:
Constant Field Values

MIN_REAL_VALUE

public static final double MIN_REAL_VALUE
See Also:
Constant Field Values

MAX_IMAGINARY_VALUE

public static final double MAX_IMAGINARY_VALUE
See Also:
Constant Field Values

MIN_IMAGINARY_VALUE

public static final double MIN_IMAGINARY_VALUE
See Also:
Constant Field Values

NaN

public static final double NaN
See Also:
Constant Field Values

NEGATIVE_REAL_INFINITY

public static final double NEGATIVE_REAL_INFINITY
See Also:
Constant Field Values

POSITIVE_REAL_INFINITY

public static final double POSITIVE_REAL_INFINITY
See Also:
Constant Field Values

NEGATIVE_IMAGINARY_INFINITY

public static final double NEGATIVE_IMAGINARY_INFINITY
See Also:
Constant Field Values

POSITIVE_IMAGINARY_INFINITY

public static final double POSITIVE_IMAGINARY_INFINITY
See Also:
Constant Field Values

TYPE

public static final java.lang.Class TYPE
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.


Quaternion

public Quaternion(Quaternion quat)
Constructs a quaternion.

Method Detail

equals

public boolean equals(java.lang.Object obj)
Compares two quaternions for equality.

Overrides:
equals in class java.lang.Object
Parameters:
obj - a quaternion

toString

public java.lang.String toString()
Returns a string representing the value of this quaternion.

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Returns a hashcode for this quaternion.

Overrides:
hashCode in class java.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:
norm in interface BanachSpace.Member
Returns:
DOCUMENT ME!

sumSquares

public double sumSquares()
Returns the sum of the squares of the components.


intValue

public int intValue()
Specified by:
intValue in class java.lang.Number

longValue

public long longValue()
Specified by:
longValue in class java.lang.Number

floatValue

public float floatValue()
Specified by:
floatValue in class java.lang.Number

doubleValue

public double doubleValue()
Specified by:
doubleValue in class java.lang.Number

negate

public AbelianGroup.Member negate()
Returns the negative of this quaternion.

Specified by:
negate in interface AbelianGroup.Member
Returns:
DOCUMENT ME!

inverse

public Field.Member inverse()
Returns the inverse of this quaternion.

Specified by:
inverse in interface Field.Member
Returns:
DOCUMENT ME!

involution

public CStarAlgebra.Member involution()
Returns the involution of this quaternion.

Specified by:
involution in interface CStarAlgebra.Member
Returns:
DOCUMENT ME!

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:
add in interface AbelianGroup.Member
Parameters:
x - a group member
Returns:
DOCUMENT ME!

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:
subtract in interface AbelianGroup.Member
Parameters:
x - a group member
Returns:
DOCUMENT ME!

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:
scalarMultiply in interface Module.Member
Parameters:
x - a ring member
Returns:
DOCUMENT ME!

multiply

public Ring.Member multiply(Ring.Member x)
Returns the multiplication of this number and another.

Specified by:
multiply in interface Ring.Member
Parameters:
x - a ring member
Returns:
DOCUMENT ME!

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:
scalarDivide in interface VectorSpace.Member
Parameters:
x - a field member
Returns:
DOCUMENT ME!

divide

public Field.Member divide(Field.Member x)
Returns the division of this number and another.

Specified by:
divide in interface Field.Member
Parameters:
x - a field member
Returns:
DOCUMENT ME!

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.

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object