com.apamax
Event Quaternion


Event that represents quaternionss in EPL.

A Quaternion can be created either from the real and i, j, k parts as floating point numbers, eg:

Quaternion q := Quaternion(3.1, 5.0, 0.1, 2.); // 3.1 + 5i + 0.1j + 2k
or by using one of the static from functions on Quaternion:

Quaternion c := Quaternion.fromComplex(Complex(1., 1.)); // 1 + i
There are also a number of convenince functions to return certain constants as Quaternions.

You can inspect a Quaternion using the scalar(), vector() and getI(), getJ() and getK() functions, which return the various parts of the Quaternion.

For operating on Quaternions this class provides operations as both static and event instance actions. Typically these have both a static version and an instance version with the name prefixed by u. The static action creates and returns a new Quaternion. The instance u form will modify the quaternion and return a reference to itself, to be used in chains of function calls. In other words, if add(a, b) corresponds to a + b, then a.uadd(b) corresponds to a += b. This has been done for performance reasons.
Action summary
 com.apamax.Quaternionstatic add(com.apamax.Quaternion a, com.apamax.Quaternion b)

Add two quaternions and return a new Quaternion with the result.
 booleanbitEquals(com.apamax.Quaternion b)

Returns true if all parts of this Quaternion are bit-equals to the corresponding parts of the argument.
 com.apamax.Quaternionstatic conjugate(com.apamax.Quaternion a)

Return a new Quaternion which is the complex conjugate of the argument.
 com.apamax.Quaternionstatic crossProduct(com.apamax.Quaternion a, com.apamax.Quaternion b)

Calculate the cross product of two Quaternions. If the Quaternions are not vector quaternions, the resultant scalar part will be the product of the scalar parts of the quaternions.
 com.apamax.Quaternionstatic divideReal(com.apamax.Quaternion a, float b)

Divide the given Quaternion by a real divisor and return the result as a new Quaternion.
 floatstatic dotProduct(com.apamax.Quaternion a, com.apamax.Quaternion b)

Calculate the dot product of two vector Quaternions. This ignores the scalar part of the Quaternions.
 com.apamax.Quaternionstatic E()

Returns Euler's number e, represented as a quaternion.
 com.apamax.Quaternionstatic exp(com.apamax.Quaternion a)

Exponentiate the argument and return the result as a new Quaternion
 stringformatFixed(integer dp)

Return the Quaternion as a string with a fixed number of decimal places. e.g. 0.30j-4.51k
 stringformatScientific(integer sf)

Return the Quaternion as a string in scientific notation e.g. 1.3e-2+5.6e10j
 com.apamax.Quaternionstatic fromComplex(com.apamax.Complex c)

Creates a Quaternion from a Complex number, with the j and k parts 0.
 com.apamax.Quaternionstatic fromIFloat(float i)

Creates a Quaternion with the given float as i and the other parts 0.
 com.apamax.Quaternionstatic fromJFloat(float j)

Creates a Quaternion with the given float as i and the other parts 0.
 com.apamax.Quaternionstatic fromKFloat(float k)

Creates a Quaternion with the given float as k and the other parts 0.
 com.apamax.Quaternionstatic fromRealFloat(float r)

Creates a Quaternion with the given float as the real part and the other parts 0.
 floatgetI()

Returns the i part of this Quaternion.
 floatgetJ()

Returns the j part of this Quaternion.
 floatgetK()

Returns the k part of this Quaternion.
 com.apamax.Quaternionstatic I()

Returns the square root of -1, i, represented as a quaternion.
 com.apamax.Quaternionstatic INFINITY()

Returns infinity + infinity*i, represented as a quaternion.
 booleanisFinite()

Returns true if all parts of this Quaternion are finite.
 booleanisInfinite()

Returns true if any part of this Quaternion is infinite.
 booleanisNaN()

Returns true if any part of this Quaternion is not a number.
 com.apamax.Quaternionstatic ln(com.apamax.Quaternion a)

Return the natural log of the argument as a new Quaternion.
 com.apamax.Quaternionstatic multiply(com.apamax.Quaternion a, com.apamax.Quaternion b)

Multiply two quaternions and return a new Quaternion with the result. Since multiplication on quaternions is not commutative a*b is not b*a for all cases. This also means that a/b is ambiguous, since it could mean a(b^-1) or (b^-1)a. To divide use multiply and reciprocal in conjuction to specify the order.
 com.apamax.Quaternionstatic multiplyReal(com.apamax.Quaternion a, float b)

Multiply the given Quaternion by a real divisor and return the result as a new Quaternion.
 com.apamax.Quaternionstatic NAN()

Returns a Quaternion which is not a number.
 com.apamax.Quaternionstatic negate(com.apamax.Quaternion a)

Return a new Quaternion which is the negation of the argument.
 floatnorm()

Return the norm of this Quaternion.
 com.apamax.Quaternionstatic ONE()

Returns 1, represented as a quaternion.
 com.apamax.Quaternionstatic PI()

Returns the constant pi, represented as a quaternion.
 com.apamax.Quaternionstatic powReal(com.apamax.Quaternion a, float b)

Return a Quaternion raised to the power of a real as a new Quaternion
 com.apamax.Quaternionstatic reciprocal(com.apamax.Quaternion a)

Return a new Quaternion which is the reciprocal of the argument.
 floatscalar()

Returns the real/scalar part of this Quaternion.
 com.apamax.Quaternionstatic subtract(com.apamax.Quaternion a, com.apamax.Quaternion b)

Subtract two quaternions and return a new Quaternion with the result.
 stringtoValueString()

Return the Quaternion as a string. e.g. 0.3-4.5i
 com.apamax.Quaternionuadd(com.apamax.Quaternion b)

Set this Complex number to add the argument and return self.
 com.apamax.Quaternionuconjugate()

Assign this to its complex conjugate and return self.
 com.apamax.QuaternionudivideReal(float b)

Set this Quaternion to be divided by the real argument and return self.
 com.apamax.Quaternionuexp()

Exponentiate this Quaternion and return self.
 com.apamax.Quaternionuln()

Sets this Quaternion to the natural logarithm of itself and return self.
 com.apamax.Quaternionumultiply(com.apamax.Quaternion b)

Set this Quaternion to multiply by the argument and return self. Since multiplication on quaternions is not commutative a*b is not b*a for all cases. This action calculates self*b. This also means that a/b is ambiguous, since it could mean a(b^-1) or (b^-1)a. To divide use umultiply and ureciprocal in conjuction to specify the order.
 com.apamax.QuaternionumultiplyReal(float b)

Set this Quaternion to be multiplied by the real argument and return self.
 com.apamax.Quaternionunegate()

Set this Quaternion to its own negation and return self.
 com.apamax.QuaternionupowReal(float x)

Raise this Quaternion to the power of a real and return self.
 com.apamax.Quaternionureciprocal()

Set this Complex number to its own reciprocal and return self.
 com.apamax.Quaternionusubtract(com.apamax.Quaternion b)

Set this Quaternion to subtract the argument and return self.
 sequence<float>vector()

Returns the imaginary/vector parts of this Quaternion.
 com.apamax.Quaternionstatic ZERO()

Returns 0, represented as a quaternion.
 
Action detail

add

com.apamax.Quaternion static add(com.apamax.Quaternion a, com.apamax.Quaternion b)
Add two quaternions and return a new Quaternion with the result.
Parameters:
a
b
Returns:
a+b.

bitEquals

boolean bitEquals(com.apamax.Quaternion b)
Returns true if all parts of this Quaternion are bit-equals to the corresponding parts of the argument.
Parameters:
b

conjugate

com.apamax.Quaternion static conjugate(com.apamax.Quaternion a)
Return a new Quaternion which is the complex conjugate of the argument.
Parameters:
a

crossProduct

com.apamax.Quaternion static crossProduct(com.apamax.Quaternion a, com.apamax.Quaternion b)
Calculate the cross product of two Quaternions. If the Quaternions are not vector quaternions, the resultant scalar part will be the product of the scalar parts of the quaternions.
Parameters:
a
b

divideReal

com.apamax.Quaternion static divideReal(com.apamax.Quaternion a, float b)
Divide the given Quaternion by a real divisor and return the result as a new Quaternion.
Parameters:
a
b
Returns:
a/b

dotProduct

float static dotProduct(com.apamax.Quaternion a, com.apamax.Quaternion b)
Calculate the dot product of two vector Quaternions. This ignores the scalar part of the Quaternions.
Parameters:
a
b

E

com.apamax.Quaternion static E()
Returns Euler's number e, represented as a quaternion.

exp

com.apamax.Quaternion static exp(com.apamax.Quaternion a)
Exponentiate the argument and return the result as a new Quaternion
Parameters:
a
Returns:
ea

formatFixed

string formatFixed(integer dp)
Return the Quaternion as a string with a fixed number of decimal places. e.g. 0.30j-4.51k
Parameters:
dp - The number of decimal places in each part.

formatScientific

string formatScientific(integer sf)
Return the Quaternion as a string in scientific notation e.g. 1.3e-2+5.6e10j
Parameters:
sf

fromComplex

com.apamax.Quaternion static fromComplex(com.apamax.Complex c)
Creates a Quaternion from a Complex number, with the j and k parts 0.
Parameters:
c

fromIFloat

com.apamax.Quaternion static fromIFloat(float i)
Creates a Quaternion with the given float as i and the other parts 0.
Parameters:
i

fromJFloat

com.apamax.Quaternion static fromJFloat(float j)
Creates a Quaternion with the given float as i and the other parts 0.
Parameters:
j

fromKFloat

com.apamax.Quaternion static fromKFloat(float k)
Creates a Quaternion with the given float as k and the other parts 0.
Parameters:
k

fromRealFloat

com.apamax.Quaternion static fromRealFloat(float r)
Creates a Quaternion with the given float as the real part and the other parts 0.
Parameters:
r

getI

float getI()
Returns the i part of this Quaternion.

getJ

float getJ()
Returns the j part of this Quaternion.

getK

float getK()
Returns the k part of this Quaternion.

I

com.apamax.Quaternion static I()
Returns the square root of -1, i, represented as a quaternion.

INFINITY

com.apamax.Quaternion static INFINITY()
Returns infinity + infinity*i, represented as a quaternion.

isFinite

boolean isFinite()
Returns true if all parts of this Quaternion are finite.

isInfinite

boolean isInfinite()
Returns true if any part of this Quaternion is infinite.

isNaN

boolean isNaN()
Returns true if any part of this Quaternion is not a number.

ln

com.apamax.Quaternion static ln(com.apamax.Quaternion a)
Return the natural log of the argument as a new Quaternion.
Parameters:
a
Returns:
ln(a)

multiply

com.apamax.Quaternion static multiply(com.apamax.Quaternion a, com.apamax.Quaternion b)
Multiply two quaternions and return a new Quaternion with the result. Since multiplication on quaternions is not commutative a*b is not b*a for all cases. This also means that a/b is ambiguous, since it could mean a(b^-1) or (b^-1)a. To divide use multiply and reciprocal in conjuction to specify the order.
Parameters:
a
b
Returns:
a*b.

multiplyReal

com.apamax.Quaternion static multiplyReal(com.apamax.Quaternion a, float b)
Multiply the given Quaternion by a real divisor and return the result as a new Quaternion.
Parameters:
a
b
Returns:
a*b

NAN

com.apamax.Quaternion static NAN()
Returns a Quaternion which is not a number.

negate

com.apamax.Quaternion static negate(com.apamax.Quaternion a)
Return a new Quaternion which is the negation of the argument.
Parameters:
a
Returns:
-a

norm

float norm()
Return the norm of this Quaternion.
Returns:
||a||

ONE

com.apamax.Quaternion static ONE()
Returns 1, represented as a quaternion.

PI

com.apamax.Quaternion static PI()
Returns the constant pi, represented as a quaternion.

powReal

com.apamax.Quaternion static powReal(com.apamax.Quaternion a, float b)
Return a Quaternion raised to the power of a real as a new Quaternion
Parameters:
a
b
Returns:
ab

reciprocal

com.apamax.Quaternion static reciprocal(com.apamax.Quaternion a)
Return a new Quaternion which is the reciprocal of the argument.
Parameters:
a
Returns:
-1/a

scalar

float scalar()
Returns the real/scalar part of this Quaternion.

subtract

com.apamax.Quaternion static subtract(com.apamax.Quaternion a, com.apamax.Quaternion b)
Subtract two quaternions and return a new Quaternion with the result.
Parameters:
a
b
Returns:
a-b.

toValueString

string toValueString()
Return the Quaternion as a string. e.g. 0.3-4.5i

uadd

com.apamax.Quaternion uadd(com.apamax.Quaternion b)
Set this Complex number to add the argument and return self.
Parameters:
b

uconjugate

com.apamax.Quaternion uconjugate()
Assign this to its complex conjugate and return self.

udivideReal

com.apamax.Quaternion udivideReal(float b)
Set this Quaternion to be divided by the real argument and return self.
Parameters:
b

uexp

com.apamax.Quaternion uexp()
Exponentiate this Quaternion and return self.
Returns:
eself

uln

com.apamax.Quaternion uln()
Sets this Quaternion to the natural logarithm of itself and return self.

umultiply

com.apamax.Quaternion umultiply(com.apamax.Quaternion b)
Set this Quaternion to multiply by the argument and return self. Since multiplication on quaternions is not commutative a*b is not b*a for all cases. This action calculates self*b. This also means that a/b is ambiguous, since it could mean a(b^-1) or (b^-1)a. To divide use umultiply and ureciprocal in conjuction to specify the order.
Parameters:
b

umultiplyReal

com.apamax.Quaternion umultiplyReal(float b)
Set this Quaternion to be multiplied by the real argument and return self.
Parameters:
b

unegate

com.apamax.Quaternion unegate()
Set this Quaternion to its own negation and return self.

upowReal

com.apamax.Quaternion upowReal(float x)
Raise this Quaternion to the power of a real and return self.
Parameters:
x
Returns:
selfx

ureciprocal

com.apamax.Quaternion ureciprocal()
Set this Complex number to its own reciprocal and return self.

usubtract

com.apamax.Quaternion usubtract(com.apamax.Quaternion b)
Set this Quaternion to subtract the argument and return self.
Parameters:
b

vector

sequence<float> vector()
Returns the imaginary/vector parts of this Quaternion.

ZERO

com.apamax.Quaternion static ZERO()
Returns 0, represented as a quaternion.