ca.uwaterloo.alumni.dwharder.Numbers
Class Quaternion

java.lang.Object
  extended by ca.uwaterloo.alumni.dwharder.Numbers.Quaternion
All Implemented Interfaces:
java.io.Serializable

public class Quaternion
extends java.lang.Object
implements java.io.Serializable

A class implementing quaternions using quartets of doubles.

This package allows the user to construct, manipulate, and model with quaternion. A quaternion is of the form a + ib + jc + kd where a, b, c, d are real numbers. The symbols i, j, and k commute with real numbers and obey the multiplication rules i2 = j2 = k2 = ijk = -1.

Quaternions are not commutative; for example, ij = k ≠-k = ji.

In the description of each non-static method, this quaternion is represented by q = a + ib + jc + kd. a and ib + jc + kd are the real and imaginary parts of q, respectively. The real numbers a, b, c, and d are the coefficients of the quaternion q. The components a, ib, jc, and kd will be referred to as the 0th, 1st, 2nd, and 3rd terms of the quatnerion q, respectively.

Any other quaternion is represented by r = e + if + jg + kh. The variables x and n are used represent real numbers and integers, respectively.

In reference to methods which must deal with branch cuts, the symbol u refers to any unit imaginary quaternion (real(u) = 0 and |u| = 1).

Instances of this class are immutable.

This class returns correct answers on branch cuts. Additionally, this class tries to give reasonable treatment to ∞ and NaN. For example, ONE.multiply(Double.POSITIVE_INFINITY) returns ∞ + i0 + j0 + k0. Most implementations would return ∞ + iNaN + jNaN + kNaN because they would simply each coefficient by the multiplier. This is probably not the desired result.

This class is based on the methods found in the Java classes Double, Math, and java.math.BigDecimal.

For those interested in rotations, see the rotateAround method.

There is very little interaction between the classes in this package. If there is a significant request for such behaviour, it will be added (seemlessly) in the future.

Since:
JDK 5.0
Version:
1.0beta 22-Mar-2005
Author:
Douglas Wilhelm Harder, Department of Electrical and Computer Engineering, University of Waterloo
See Also:
Double, Math, Serialized Form

Field Summary
static Quaternion I
          The constant i.
static Quaternion J
          The constant j.
static Quaternion K
          The constant k.
static Quaternion NaN
          The constant NaN + iNaN + jNaN + kNaN.
static Quaternion ONE
          The constant 1.
static Quaternion ZERO
          The constant 0.
 
Constructor Summary
Quaternion(double a)
          Generates the quaternion a + i0 + j0 + k0.
Quaternion(double[] v)
          Generates a quaternion based on the entries of the array v.
Quaternion(double x, double[] v)
          Generates the quaternion x + iv0 + jv1 + kv2.
Quaternion(double b, double c, double d)
          Generates the imaginary quaternion 0 + ib + jc + kd.
Quaternion(double a, double b, double c, double d)
          Generates the quaternion a + ib + jc + kd.
 
Method Summary
 double abs()
          Returns the absolute value of this quaternion q.
 double abs2()
          Returns the square of the absolute value of this quaternion q.
 double abs2Imag()
          Returns the square of the absolute value of the imaginary part of this quaternion q.
 double absImag()
          Returns the absolute value of the imaginary part of this quaternion q.
 Quaternion acos()
          Returns the principal inverse cosine of this quaternion q.
 Quaternion acos(Quaternion u)
          Returns the principal inverse cosine of this quaternion q.
 Quaternion acosh()
          Returns the principal inverse hyperbolic cosine of this quaternion q.
 Quaternion acosh(Quaternion u)
          Returns the principal inverse hyperbolic cosine of this quaternion q.
 Quaternion acot()
          Returns the principal inverse cotangent of this quaternion q.
 Quaternion acot(Quaternion u)
          Returns the principal inverse cotangent of this quaternion q.
 Quaternion acoth()
          Returns the principal inverse hyperbolic cotangent of this quaternion q.
 Quaternion acoth(Quaternion u)
          Returns the principal inverse hyperbolic cotangent of this quaternion q.
 Quaternion acsc()
          Returns the principal inverse cosecant of this quaternion q.
 Quaternion acsc(Quaternion u)
          Returns the principal inverse cosecant of this quaternion q.
 Quaternion acsch()
          Returns the principal inverse hyperbolic cosecant of this quaternion q.
 Quaternion acsch(Quaternion u)
          Returns the principal inverse hyperbolic cosecant of this quaternion q.
 Quaternion add(double x)
          Returns the sum of this quaternion q and the real number x.
 Quaternion add(int n, double x)
          Returns this quaternion q with x added onto its nth term.
 Quaternion add(Quaternion r)
          Returns the sum of this quaternion q and the quaternion r = e + if + jg + kh.
 Quaternion addI(double x)
          Returns the sum of this quaternion q and the imaginary number ix.
 Quaternion addJ(double x)
          Returns the sum of this quaternion q and the imaginary number jx.
 Quaternion addK(double x)
          Returns the sum of this quaternion q and the imaginary number kx.
 double argument()
          Returns the argument of this quaternion q.
 Quaternion asec()
          Returns the principal inverse secant of this quaternion q.
 Quaternion asec(Quaternion u)
          Returns the principal inverse secant of this quaternion q.
 Quaternion asech()
          Returns the principal inverse hyperbolic secant of this quaternion q.
 Quaternion asech(Quaternion u)
          Returns the principal inverse hyperbolic secant of this quaternion q.
 Quaternion asin()
          Returns the principal inverse sine of this quaternion q.
 Quaternion asin(Quaternion u)
          Returns the principal inverse sine of this quaternion q.
 Quaternion asinh()
          Returns the principal inverse hyperbolic sine of this quaternion q.
 Quaternion asinh(Quaternion u)
          Returns the principal inverse hyperbolic sine of this quaternion q.
 Quaternion atan()
          Returns the principal inverse tangent of this quaternion q.
 Quaternion atan(Quaternion u)
          Returns the principal inverse tangent of this quaternion q.
 Quaternion atanh()
          Returns the principal inverse hyperbolic tangent of this quaternion q.
 Quaternion atanh(Quaternion u)
          Returns the principal inverse hyperbolic tangent of this quaternion q.
 Quaternion ceil()
          Returns the ceiling of each of the coefficients of this quaternion q.
 double coefficient(int n)
          Returns the coefficient of the nth term of this quaternion q.
 Quaternion conjugate()
          Returns the conjugate of this quaternion q.
 Quaternion cos()
          Returns the cosine of this quaternion q.
 Quaternion cosh()
          Returns the hyperbolic cosine of this quaternion q.
 Quaternion cot()
          Returns the cotangent of this quaternion q.
 Quaternion coth()
          Returns the hyperbolic cotangent of this quaternion q.
 Quaternion csc()
          Returns the cosecant of this quaternion q.
 Quaternion csch()
          Returns the hyperbolic cosecant of this quaternion q.
 Quaternion divide(Quaternion r)
          Returns the quotient of this quaternion q over the quaternion r = e + if + jg + kh.
 boolean equals(java.lang.Object r)
          This quaternion q equals the quaternion r = e + if + jg + kh if a == e, b == f, c == g, and d == h.
 boolean equals(java.lang.Object r, double eps)
          Returns true if this quaternion q equals the quaternion r = e + if + jg + kh.
 Quaternion exp()
          Returns Euler's number (e) raised to the power of this quaternion q.
 Quaternion floor()
          Returns the floor of each of the coefficients of this quaternion q.
 int hashCode()
          Returns a hash code for the this quaternion q based on the coefficients.
 Quaternion horner(double[] v)
          Evaluate the polynomial with real coefficients, given by the array of doubles v, at this quaternion q.
 Quaternion imag()
          Returns the imaginary part of this quaternion q.
 double imagI()
          Returns the coefficient of i of this quaternion q.
static java.lang.String[] imaginaryUnits(java.lang.String[] units)
          Set the strings to be used for the three imaginary units.
 double imagJ()
          Returns the coefficient of j of this quaternion q.
 double imagK()
          Returns the coefficient of k of this quaternion q.
 boolean isImaginary()
          Returns true if the real part of this quaternion q is zero and false otherwise.
 boolean isImaginary(int n)
          Returns true if the nth imaginary coefficient of this quaternion q is the only non-zero coefficient and false otherwise.
 boolean isImaginaryI()
          Returns true if the only non-zero coefficient of this quaternion q is the coefficient of i and false otherwise.
 boolean isImaginaryJ()
          Returns true if the only non-zero coefficient of this quaternion q is the coefficient of j and false otherwise.
 boolean isImaginaryK()
          Returns true if the only non-zero coefficient of this quaternion q is the coefficient of k and false otherwise.
 boolean isInfinite()
          Returns true if any coefficient of this quaternion q is infinite and false otherwise.
 boolean isNaN()
          Returns true if any coefficient of this quaternion q is not-a-number (NaN) and false otherwise.
 boolean isReal()
          Returns true if all the coefficients of the imaginary part of this quaternion q are zero, otherwise false.
 boolean isZero()
          Returns true if all coefficients of this quaternion q are zero, otherwise false.
 Quaternion log()
          Returns the natural logarithm of this quaternion q.
 Quaternion log(Quaternion u)
          Returns the natural logarithm of this quaternion q.
 Quaternion log10()
          Returns the logarithm base 10 of this quaternion q.
 Quaternion log10(Quaternion u)
          Returns the natural logarithm of this quaternion q.
 Quaternion multiply(double x)
          Returns the product of this quaternion q and the real number x.
 Quaternion multiply(Quaternion r)
          Returns the product of this quaternion q and the quaternion r = e + if + jg + kh.
 Quaternion negate()
          Returns the negative of this quaternion q.
 Quaternion pow(double x)
          Returns this quaternion q raised to the real number x.
 Quaternion pow(int n)
          Returns this quaternion q raised to the integer n.
 Quaternion pow(Quaternion r)
          Returns this quaternion q raised to the quaternion r.
 Quaternion project(boolean[] v)
          Project this quaternion q onto the subspace defined by the boolean vector v.
 Quaternion project(int n)
          Project this quaternion q onto the nth term.
static Quaternion random()
          A factory method for constructing a quaternion with a random real and imaginary parts.
 Quaternion random(boolean[] v)
          A factory method to create a random quaternion defined by the boolean vector v.
static Quaternion random(int n)
          A factory method for constructing a quaternion with a random nth coefficient.
static Quaternion randomImaginary()
          A factory method for constructing a imaginary quaternion with random imaginary coefficients.
static Quaternion randomReal()
          A factory method for constructing a quaternion with a random real part.
 double real()
          Returns the real part of this quaternion q.
 Quaternion rint()
          Returns each coefficient of the quaternion q rounded to the nearest double equal to an integer.
 Quaternion rotateAround(Quaternion r)
          Rotate this imaginary quaternion q around the imaginary part of r, the angle of rotation being twice the argument of r.
 Quaternion sec()
          Returns the secant of this quaternion q.
 Quaternion sech()
          Returns the hyperbolic secant of this quaternion q.
 Quaternion signum()
          Returns a normalized form of this quaternion q when it is non-zero and q otherwise.
 Quaternion sin()
          Returns the sine of this quaternion q.
 Quaternion sinh()
          Returns the hyperbolic sine of this quaternion q.
 Quaternion sqr()
          Returns the square of this quaternion q.
 Quaternion sqrt()
          Returns the square root of this quaternion q.
 Quaternion sqrt(Quaternion u)
          Returns the square root of this quaternion q.
 Quaternion subtract(Quaternion r)
          Returns the difference between this quaternion q and the quaternion r = e + if + jc + kd.
 Quaternion tan()
          Returns the tangent of this quaternion q.
 Quaternion tanh()
          Returns the hyperbolic tangent of this quaternion q.
 double[] toArray()
          Converts this quaternion q in to an array of four doubles.
 double[] toArray(byte[] v)
          Convert this quaternion q to an array of doubles.
 double[] toImagArray()
          Converts the imaginary part of this quaternion q in to an array of three doubles.
 java.lang.String toString()
          Returns a string representing this quaternion q.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final Quaternion ZERO
The constant 0.


ONE

public static final Quaternion ONE
The constant 1.


I

public static final Quaternion I
The constant i.


J

public static final Quaternion J
The constant j.


K

public static final Quaternion K
The constant k.


NaN

public static final Quaternion NaN
The constant NaN + iNaN + jNaN + kNaN.

Constructor Detail

Quaternion

public Quaternion(double a,
                  double b,
                  double c,
                  double d)

Generates the quaternion a + ib + jc + kd.

Parameters:
a - the real part
b - the coefficent of i
c - the coefficent of j
d - the coefficent of k

Quaternion

public Quaternion(double a)

Generates the quaternion a + i0 + j0 + k0.

Parameters:
a - the real part

Quaternion

public Quaternion(double b,
                  double c,
                  double d)

Generates the imaginary quaternion 0 + ib + jc + kd.

Parameters:
b - the coefficent of i
c - the coefficent of j
d - the coefficent of kt

Quaternion

public Quaternion(double[] v)

Generates a quaternion based on the entries of the array v.

An array v of length 4 defines the quaternion v0 + iv1 + jv2 + kv3, and

an array v of length 3 defines the imaginary quaternion 0 + iv1 + jv2 + kv3.

Parameters:
v - array of length 3 or 4

Quaternion

public Quaternion(double x,
                  double[] v)

Generates the quaternion x + iv0 + jv1 + kv2.

Parameters:
x - the real part
v - an array defining the coefficients of the imaginary part
Method Detail

random

public static final Quaternion random()
A factory method for constructing a quaternion with a random real and imaginary parts.

Returns:
r0 + ir1 + jr2 + kr3, where each rn is a random double.
See Also:
Math.random()

random

public static final Quaternion random(int n)

A factory method for constructing a quaternion with a random nth coefficient.

Returns:
r, ir, jr, or kr where r is a random double
See Also:
Math.random()

random

public final Quaternion random(boolean[] v)

A factory method to create a random quaternion defined by the boolean vector v.

In the result, the coefficient of the nth term is a random double if vn == true.

Parameters:
v - an array indicating a subspace
Returns:
a random quaternion s
See Also:
Math.random()

randomReal

public static final Quaternion randomReal()

A factory method for constructing a quaternion with a random real part.

Returns:
r where r is a random double
See Also:
Math.random()

randomImaginary

public static final Quaternion randomImaginary()
A factory method for constructing a imaginary quaternion with random imaginary coefficients.

Returns:
0 + ir1 + jr2 + kr3, where each rn is a random double.
See Also:
Math.random()

equals

public final boolean equals(java.lang.Object r)

This quaternion q equals the quaternion r = e + if + jg + kh if a == e, b == f, c == g, and d == h.

Note: NaN == NaN returns false but 0.0 == -0.0 returns true.

Overrides:
equals in class java.lang.Object
Returns:
true if the quaternions are equal.

equals

public final boolean equals(java.lang.Object r,
                            double eps)

Returns true if this quaternion q equals the quaternion r = e + if + jg + kh.

Two nonzero quaternions o and p are equal up to ε if |q - r|/min( |q|, |r| ) < ε.

If q = 0 or r = 0 then we check that |q| < ε or |r| < ε, respectively.

Parameters:
eps - the allowable relative difference: greater than or equal to 0
Returns:
true if the quaternions are approximation equal

hashCode

public final int hashCode()

Returns a hash code for the this quaternion q based on the coefficients.

Overrides:
hashCode in class java.lang.Object

toString

public final java.lang.String toString()

Returns a string representing this quaternion q.

If N0 = abs(a), N1 = abs(b), N2 = abs(c), and N3 = abs(d), then the return value is "[-]N0 (+|-) iN1 (+|-) jN2 (+|-) kN3".

Overrides:
toString in class java.lang.Object
Returns:
a string of the form "a + ib + jc + kd"

imaginaryUnits

public static final java.lang.String[] imaginaryUnits(java.lang.String[] units)

Set the strings to be used for the three imaginary units.

For example, double[] {"i", "e'", "i'"}.

Returns:
the previously used array of imaginary units

toArray

public final double[] toArray()
Converts this quaternion q in to an array of four doubles.

Returns:
new double[] {a, b, c, d}

toArray

public final double[] toArray(byte[] v)

Convert this quaternion q to an array of doubles.

The coefficient placed into the nth entry of the array is determined by vn.

Parameters:
v - an array of 0, 1, 2, or 3, indicating which coefficient is to be placed into the nth entry of the array
Returns:
an array of doubles of coefficients as specified by v

toImagArray

public final double[] toImagArray()
Converts the imaginary part of this quaternion q in to an array of three doubles.

Returns:
new double[] {b, c, d}

isZero

public final boolean isZero()
Returns true if all coefficients of this quaternion q are zero, otherwise false.

Returns:
true if q is zero

isReal

public final boolean isReal()
Returns true if all the coefficients of the imaginary part of this quaternion q are zero, otherwise false.

Returns:
true if q is real

isImaginary

public final boolean isImaginary()
Returns true if the real part of this quaternion q is zero and false otherwise.

Returns:
true if q is imaginary

isImaginary

public final boolean isImaginary(int n)
Returns true if the nth imaginary coefficient of this quaternion q is the only non-zero coefficient and false otherwise.

Returns:
true if q is non-zero in only one component

isImaginaryI

public final boolean isImaginaryI()
Returns true if the only non-zero coefficient of this quaternion q is the coefficient of i and false otherwise.

Returns:
true if q = 0 + ib + j0 + k0

isImaginaryJ

public final boolean isImaginaryJ()
Returns true if the only non-zero coefficient of this quaternion q is the coefficient of j and false otherwise.

Returns:
true if q = 0 + i0 + jc + k0

isImaginaryK

public final boolean isImaginaryK()
Returns true if the only non-zero coefficient of this quaternion q is the coefficient of k and false otherwise.

Returns:
true if q = 0 + i0 + j0 + kd

isNaN

public final boolean isNaN()
Returns true if any coefficient of this quaternion q is not-a-number (NaN) and false otherwise.

Returns:
true if any coefficient of q is NaN
See Also:
Double.isNaN(double)

isInfinite

public final boolean isInfinite()
Returns true if any coefficient of this quaternion q is infinite and false otherwise.

Returns:
true if any coefficient of q is infinite
See Also:
Double.isInfinite(double)

abs

public final double abs()

Returns the absolute value of this quaternion q.

abs(q) = |q| = sqrt(a2 + b2 + c2 + d2)

Special case:

Returns:
|q|

abs2

public final double abs2()

Returns the square of the absolute value of this quaternion q.

abs2(q) = |q|2 = a2 + b2 + c2 + d2

Special case:

Returns:
|q|2

absImag

public final double absImag()

Returns the absolute value of the imaginary part of this quaternion q.

abs(imag(q)) = |imag(q)| = sqrt(b2 + c2 + d2)

Special case:

Returns:
|imag(q)|

abs2Imag

public final double abs2Imag()

Returns the square of the absolute value of the imaginary part of this quaternion q.

abs2(imag(q)) = |imag(q)|2 = b2 + c2 + d2

Special case:

Returns:
|imag(q)|2

real

public final double real()

Returns the real part of this quaternion q.

real(q) = a.

Returns:
a
See Also:
project(int)

imag

public final Quaternion imag()

Returns the imaginary part of this quaternion q.

imag(q) = ib + jc + kd

Returns:
0 + ib + jc + kd
See Also:
project(int)

imagI

public final double imagI()

Returns the coefficient of i of this quaternion q.

imagI(q) = b

Returns:
b

imagJ

public final double imagJ()

Returns the coefficient of j of this quaternion q.

imagJ(q) = c

Returns:
c

imagK

public final double imagK()

Returns the coefficient of k of this quaternion q.

imagK(q) = d

Returns:
d

coefficient

public final double coefficient(int n)

Returns the coefficient of the nth term of this quaternion q.

Parameters:
n - the number (0, 1, 2, or 3) of the coefficient to return
Returns:
the nth coefficient

project

public final Quaternion project(int n)

Project this quaternion q onto the nth term.

Parameters:
n - the number of term (0, 1, 2, 3) to be projected onto
Returns:
a, ib, jc, or kd

project

public final Quaternion project(boolean[] v)

Project this quaternion q onto the subspace defined by the boolean vector v.

In the result, the coefficient of the nth term is set to 0.0 if vn == false.

Parameters:
v - an array indicating the terms to project onto
Returns:
a perpendicular projection of q

conjugate

public final Quaternion conjugate()

Returns the conjugate of this quaternion q.

conjugate(q) = a - ib - jc - kd

Returns:
a - ib - jc - kd

argument

public final double argument()

Returns the argument of this quaternion q.

This is a value on the interval [0, &pi]. For non-zero q, if u = imag(q)/|imag(q)| then q = |q|eu argument(q).

argument(q) = atan2( |imag(q)|, a )

Returns:
atan2( |imag(q)|, a )

signum

public final Quaternion signum()

Returns a normalized form of this quaternion q when it is non-zero and q otherwise.

Returns:
q/|q| for nonzero q

add

public final Quaternion add(Quaternion r)

Returns the sum of this quaternion q and the quaternion r = e + if + jg + kh.

q + r = (a + e) + i(b + f) + j(c + g) + k(d + h)

Returns:
q + r

add

public final Quaternion add(int n,
                            double x)

Returns this quaternion q with x added onto its nth term.

Parameters:
n - the number (0, 1, 2, ..., 15) of the onto which to add x
Returns:
q with x added onto the coefficient of the nth term

add

public final Quaternion add(double x)

Returns the sum of this quaternion q and the real number x.

q + x = (a + x) + ib + jc + kd

Returns:
q + x

addI

public final Quaternion addI(double x)

Returns the sum of this quaternion q and the imaginary number ix.

q + ix = a + i(b + x) + jc + kd

Returns:
q + ix

addJ

public final Quaternion addJ(double x)

Returns the sum of this quaternion q and the imaginary number jx.

q + jx = a + ib + j(c + x) + kd

Returns:
q + jx

addK

public final Quaternion addK(double x)

Returns the sum of this quaternion q and the imaginary number kx.

q + x = a + ib + jc + k(d + x)

Returns:
q + kx

subtract

public final Quaternion subtract(Quaternion r)

Returns the difference between this quaternion q and the quaternion r = e + if + jc + kd.

q - r = (a - e) + i(b - f) + j(c - g) + k(d - h)

Returns:
q - r

negate

public final Quaternion negate()

Returns the negative of this quaternion q.

-q = -a - ib - jc - kd

Returns:
-q

multiply

public final Quaternion multiply(Quaternion r)

Returns the product of this quaternion q and the quaternion r = e + if + jg + kh.

Multiplication is distributive with the following multiplication matrix for 1 and the imaginary units:

×1ijk
11ijk
ii-1k-j
jj-k-1i
kkj-i-1

In general, qr ≠ rq.

* @return qr


multiply

public final Quaternion multiply(double x)

Returns the product of this quaternion q and the real number x.

qx = ax + ibx + jcx + kdx

Returns:
qx

divide

public final Quaternion divide(Quaternion r)

Returns the quotient of this quaternion q over the quaternion r = e + if + jg + kh.

q/r = qconjugate(r)/|r|2. In general, q/r ≠ (1/r)q.

Returns:
q/r

pow

public final Quaternion pow(Quaternion r)

Returns this quaternion q raised to the quaternion r.

Returns:
qr

pow

public final Quaternion pow(double x)

Returns this quaternion q raised to the real number x.

Returns:
qx

pow

public final Quaternion pow(int n)

Returns this quaternion q raised to the integer n.

Returns:
qn

sqr

public final Quaternion sqr()

Returns the square of this quaternion q.

Returns:
o2

horner

public final Quaternion horner(double[] v)

Evaluate the polynomial with real coefficients, given by the array of doubles v, at this quaternion q.

If n = v.length - 1 then this method evaluates v0 + v1q + ... + vnqn using Horner's rule.

Returns:
v0 + v1q + ... + vnqn.

sqrt

public final Quaternion sqrt()

Returns the square root of this quaternion q.

The branch cut is on (-∞, 0).

Returns:
sqrt(q)

sqrt

public final Quaternion sqrt(Quaternion u)

Returns the square root of this quaternion q.

The branch cut is on (-∞, 0).

On the branch cuts, the imaginary part is a multiple of the imaginary quaternion u.

Parameters:
u - a non-zero imaginary quaternion
Returns:
sqrt(q)

rotateAround

public final Quaternion rotateAround(Quaternion r)
Rotate this imaginary quaternion q around the imaginary part of r, the angle of rotation being twice the argument of r.

Parameters:
r - a finite non-zero imaginary quaternion
Returns:
q rotated around the imaginary part of q

exp

public final Quaternion exp()

Returns Euler's number (e) raised to the power of this quaternion q.

If u = imag(q)/|imag(q)| then eq = ea(cos|imag(q)| + u sin|imag(q)|).

Returns:
eq
See Also:
log()

log

public final Quaternion log()

Returns the natural logarithm of this quaternion q.

The branch cut is on (-∞, 0].

Returns:
log(q)
See Also:
exp()

log

public final Quaternion log(Quaternion u)

Returns the natural logarithm of this quaternion q.

The branch cut is on (-∞, 0].

On the branch cuts, the imaginary part is a multiple of the imaginary quaternion u.

Parameters:
u - a non-zero imaginary quaternion
Returns:
log(q)
See Also:
exp()

log10

public final Quaternion log10()

Returns the logarithm base 10 of this quaternion q.

The branch cut is on (-∞, 0].

Returns:
log10(q)

log10

public final Quaternion log10(Quaternion u)

Returns the natural logarithm of this quaternion q.

The branch cut is on (-∞, 0].

On the branch cuts, the imaginary part is a multiple of the imaginary quaternion u.

Parameters:
u - a non-zero imaginary quaternion
Returns:
log10(q)

sin

public final Quaternion sin()

Returns the sine of this quaternion q.

Returns:
sin(q)
See Also:
asin()

cos

public final Quaternion cos()

Returns the cosine of this quaternion q.

Returns:
cos(q)
See Also:
acos()

tan

public final Quaternion tan()

Returns the tangent of this quaternion q.

Returns:
tan(q)
See Also:
atan()

sec

public final Quaternion sec()

Returns the secant of this quaternion q.

Returns:
sec(q)
See Also:
asec()

csc

public final Quaternion csc()

Returns the cosecant of this quaternion q.

Returns:
csc(q)
See Also:
acsc()

cot

public final Quaternion cot()

Returns the cotangent of this quaternion q.

Returns:
cot(q)
See Also:
acot()

sinh

public final Quaternion sinh()

Returns the hyperbolic sine of this quaternion q.

Returns:
sinh(q)
See Also:
asinh()

cosh

public final Quaternion cosh()

Returns the hyperbolic cosine of this quaternion q.

Returns:
cosh(q)
See Also:
acosh()

tanh

public final Quaternion tanh()

Returns the hyperbolic tangent of this quaternion q.

Returns:
tanh(q)
See Also:
atanh()

sech

public final Quaternion sech()

Returns the hyperbolic secant of this quaternion q.

Returns:
sech(q)
See Also:
asech()

csch

public final Quaternion csch()

Returns the hyperbolic cosecant of this quaternion q.

Returns:
csch(q)
See Also:
acsch()

coth

public final Quaternion coth()

Returns the hyperbolic cotangent of this quaternion q.

Returns:
coth(q)
See Also:
acoth()

asin

public final Quaternion asin()

Returns the principal inverse sine of this quaternion q.

The branch cuts are (-∞, -1) and (1, ∞).

Returns:
asin(q)
See Also:
sin()

asin

public final Quaternion asin(Quaternion u)

Returns the principal inverse sine of this quaternion q.

The branch cuts are (-∞, -1) and (1, ∞).

On the branch cuts, the imaginary part is a multiple of the imaginary quaternion u.

Parameters:
u - a non-zero imaginary quaternion
Returns:
asin(q)
See Also:
sin()

acos

public final Quaternion acos()

Returns the principal inverse cosine of this quaternion q.

The branch cuts are (-∞, -1) and (1, ∞).

Returns:
acos(q)
See Also:
cos()

acos

public final Quaternion acos(Quaternion u)

Returns the principal inverse cosine of this quaternion q.

The branch cuts are (-∞, -1) and (1, ∞).

On the branch cuts, the imaginary part is a multiple of the imaginary quaternion u.

Parameters:
u - a non-zero imaginary quaternion
Returns:
acos(q)
See Also:
cos()

atan

public final Quaternion atan()

Returns the principal inverse tangent of this quaternion q.

The branch cuts are (-u∞, -u] and [u, u∞).

Returns:
atan(q)
See Also:
tan()

atan

public final Quaternion atan(Quaternion u)

Returns the principal inverse tangent of this quaternion q.

The branch cuts are (-u∞, -u] and [u, u∞).

On the branch cuts, the imaginary part is a multiple of the imaginary quaternion u.

Parameters:
u - a non-zero imaginary quaternion
Returns:
atan(q)
See Also:
tan()

asec

public final Quaternion asec()

Returns the principal inverse secant of this quaternion q.

The branch cut is (-1, 1).

Returns:
asec(q)
See Also:
sec()

asec

public final Quaternion asec(Quaternion u)

Returns the principal inverse secant of this quaternion q.

The branch cut is (-1, 1).

On the branch cuts, the imaginary part is a multiple of the imaginary quaternion u.

Parameters:
u - a non-zero imaginary quaternion
Returns:
asec(q)
See Also:
sec()

acsc

public final Quaternion acsc()

Returns the principal inverse cosecant of this quaternion q.

The branch cut is (-1, 1).

Returns:
acsc(q)
See Also:
csc()

acsc

public final Quaternion acsc(Quaternion u)

Returns the principal inverse cosecant of this quaternion q.

The branch cut is (-1, 1).

On the branch cuts, the imaginary part is a multiple of the imaginary quaternion u.

Parameters:
u - a non-zero imaginary quaternion
Returns:
acsc(q)
See Also:
csc()

acot

public final Quaternion acot()

Returns the principal inverse cotangent of this quaternion q.

The branch cut is (-u, u).

Returns:
acot(q)
See Also:
cot()

acot

public final Quaternion acot(Quaternion u)

Returns the principal inverse cotangent of this quaternion q.

The branch cut is (-u, u).

On the branch cuts, the imaginary part is a multiple of the imaginary quaternion u.

Parameters:
u - a non-zero imaginary quaternion
Returns:
acot(q)
See Also:
cot()

asinh

public final Quaternion asinh()

Returns the principal inverse hyperbolic sine of this quaternion q.

The branch cuts are (-u∞, -u) and (u, u∞).

Returns:
asinh(q)
See Also:
sinh()

asinh

public final Quaternion asinh(Quaternion u)

Returns the principal inverse hyperbolic sine of this quaternion q.

The branch cuts are (-u∞, -u) and (u, u∞).

On the branch cuts, the imaginary part is a multiple of the imaginary quaternion u.

Parameters:
u - a non-zero imaginary quaternion
Returns:
asinh(q)
See Also:
sinh()

acosh

public final Quaternion acosh()

Returns the principal inverse hyperbolic cosine of this quaternion q.

The branch cut is (-∞, 1).

Returns:
acosh(q)
See Also:
cosh()

acosh

public final Quaternion acosh(Quaternion u)

Returns the principal inverse hyperbolic cosine of this quaternion q.

The branch cut is (-∞, 1).

On the branch cuts, the imaginary part is a multiple of the imaginary quaternion u.

Parameters:
u - a non-zero imaginary quaternion
Returns:
acosh(q)
See Also:
cosh()

atanh

public final Quaternion atanh()

Returns the principal inverse hyperbolic tangent of this quaternion q.

The branch cuts are (-∞, -1] and [1, ∞).

Returns:
atanh(q)
See Also:
tanh()

atanh

public final Quaternion atanh(Quaternion u)

Returns the principal inverse hyperbolic tangent of this quaternion q.

The branch cuts are (-∞, -1] and [1, ∞).

On the branch cuts, the imaginary part is a multiple of the imaginary quaternion u.

Parameters:
u - a non-zero imaginary quaternion
Returns:
atanh(q)
See Also:
tanh()

asech

public final Quaternion asech()

Returns the principal inverse hyperbolic secant of this quaternion q.

The branch cuts are (-∞, 0] and (1, ∞).

Returns:
asech(q)
See Also:
sech()

asech

public final Quaternion asech(Quaternion u)

Returns the principal inverse hyperbolic secant of this quaternion q.

The branch cuts are (-∞, 0] and (1, ∞).

On the branch cuts, the imaginary part is a multiple of the imaginary quaternion u.

Parameters:
u - a non-zero imaginary quaternion
Returns:
asech(q)
See Also:
sech()

acsch

public final Quaternion acsch()

Returns the principal inverse hyperbolic cosecant of this quaternion q.

The branch cut is (-i, i).

Returns:
acsch(q)
See Also:
csch()

acsch

public final Quaternion acsch(Quaternion u)

Returns the principal inverse hyperbolic cosecant of this quaternion q.

The branch cut is (-u, u).

On the branch cuts, the imaginary part is a multiple of the imaginary quaternion u.

Parameters:
u - a non-zero imaginary quaternion
Returns:
acsch(q)
See Also:
csch()

acoth

public final Quaternion acoth()

Returns the principal inverse hyperbolic cotangent of this quaternion q.

The branch cut is [-1, 1].

Returns:
acoth(q)
See Also:
coth()

acoth

public final Quaternion acoth(Quaternion u)

Returns the principal inverse hyperbolic cotangent of this quaternion q.

The branch cut is [-1, 1].

On the branch cuts, the imaginary part is a multiple of the imaginary quaternion u.

Parameters:
u - a non-zero imaginary quaternion
Returns:
acoth(q)
See Also:
coth()

ceil

public final Quaternion ceil()

Returns the ceiling of each of the coefficients of this quaternion q.

Returns:
ceil(a) + iceil(b) + jceil(c) + kceil(d)
See Also:
Math.ceil(double)

floor

public final Quaternion floor()

Returns the floor of each of the coefficients of this quaternion q.

Returns:
floor(a) + ifloor(b) + jfloor(c) + kfloor(d)
See Also:
Math.floor(double)

rint

public final Quaternion rint()

Returns each coefficient of the quaternion q rounded to the nearest double equal to an integer.

Returns:
rint(a) + irint(b) + jrint(c) + krint(d)
See Also:
Math.rint(double)