Package org.ojalgo.scalar
Class Quaternion
java.lang.Object
org.ojalgo.scalar.Quaternion
- All Implemented Interfaces:
Comparable<Quaternion>
,Field<Scalar<Quaternion>>
,Group
,Group.Additive<Scalar<Quaternion>>
,Group.Multiplicative<Scalar<Quaternion>>
,NormedVectorSpace<Scalar<Quaternion>,
,Quaternion> Operation
,Operation.Addition<Scalar<Quaternion>>
,Operation.Division<Scalar<Quaternion>>
,Operation.Multiplication<Scalar<Quaternion>>
,Operation.Subtraction<Scalar<Quaternion>>
,Ring<Scalar<Quaternion>>
,ScalarOperation
,ScalarOperation.Addition<Scalar<Quaternion>,
,Quaternion> ScalarOperation.Division<Scalar<Quaternion>,
,Quaternion> ScalarOperation.Multiplication<Scalar<Quaternion>,
,Quaternion> ScalarOperation.Subtraction<Scalar<Quaternion>,
,Quaternion> VectorSpace<Scalar<Quaternion>,
,Quaternion> Scalar<Quaternion>
,SelfDeclaringScalar<Quaternion>
,Access1D<Double>
,Access2D<Double>
,Access2D.Collectable<Double,
,Mutate2D> AccessScalar<Quaternion>
,Structure1D
,Structure2D
,Transformation2D<Double>
,Tensor<Quaternion,
,Scalar<Quaternion>> NumberContext.Enforceable<Quaternion>
,NumberDefinition
public final class Quaternion
extends Object
implements SelfDeclaringScalar<Quaternion>, Access2D<Double>, Transformation2D<Double>, Access2D.Collectable<Double,Mutate2D>
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.ojalgo.structure.Access2D
Access2D.Aggregatable<N extends Comparable<N>>, Access2D.Collectable<N extends Comparable<N>,
R extends Mutate2D>, Access2D.ColumnView<N extends Comparable<N>>, Access2D.ElementView<N extends Comparable<N>>, Access2D.RowView<N extends Comparable<N>>, Access2D.SelectionView<N extends Comparable<N>>, Access2D.Sliceable<N extends Comparable<N>>, Access2D.Visitable<N extends Comparable<N>> Nested classes/interfaces inherited from interface org.ojalgo.algebra.Group
Group.Additive<T>, Group.Multiplicative<T>
Nested classes/interfaces inherited from interface org.ojalgo.algebra.Operation
Operation.Addition<T>, Operation.Division<T>, Operation.Multiplication<T>, Operation.Subtraction<T>
Nested classes/interfaces inherited from interface org.ojalgo.scalar.Scalar
Scalar.Factory<N extends Comparable<N>>
Nested classes/interfaces inherited from interface org.ojalgo.algebra.ScalarOperation
ScalarOperation.Addition<T,
N extends Comparable<N>>, ScalarOperation.Division<T, N extends Comparable<N>>, ScalarOperation.Multiplication<T, N extends Comparable<N>>, ScalarOperation.Subtraction<T, N extends Comparable<N>> Nested classes/interfaces inherited from interface org.ojalgo.structure.Structure1D
Structure1D.BasicMapper<T>, Structure1D.IndexMapper<T>, Structure1D.IntIndex, Structure1D.Logical<S extends Structure1D,
B extends Structure1D.Logical<S, B>>, Structure1D.LongIndex, Structure1D.LoopCallback Nested classes/interfaces inherited from interface org.ojalgo.structure.Structure2D
Structure2D.IntRowColumn, Structure2D.Logical<S extends Structure2D,
B extends Structure2D.Logical<S, B>>, Structure2D.LongRowColumn, Structure2D.ReducibleTo1D<R extends Structure1D>, Structure2D.Reshapable, Structure2D.RowColumnKey<R, C>, Structure2D.RowColumnMapper<R, C> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final double
static final Scalar.Factory
<Quaternion> final double
static final Quaternion
static final Quaternion
static final Quaternion
final double
static final Quaternion
final double
static final Quaternion
private final boolean
private final boolean
private final double
static final Quaternion
static final Quaternion
static final Quaternion
static final Quaternion
static final Quaternion
-
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
Quaternion
(double scalar) private
Quaternion
(double[] vector) private
Quaternion
(double scalar, double[] vector) (package private)
Quaternion
(double i, double j, double k) (package private)
Quaternion
(double scalar, double i, double j, double k) -
Method Summary
Modifier and TypeMethodDescriptionadd
(double arg) add
(Quaternion arg) double
angle()
private double
private double
int
compareTo
(Quaternion other) First compares the real values.This method will (most likely) be moved to some other interface in the future! Just have to figure out where it fits...long
count()
count() == countRows() * countColumns()long
Only need to implement if the structure may contain more than Integer.MAX_VALUE elements.long
Only need to implement if the structure may contain more than Integer.MAX_VALUE elements.divide
(double arg) divide
(Quaternion arg) Will calculatethis * reciprocal(arg)
which is not the same asreciprocal(arg) * this
.double
double
doubleValue
(int index) double
doubleValue
(int row, int col) Extracts one element of this matrix as a double.enforce
(NumberContext context) boolean
float
get()
get
(long index) get
(long row, long col) int
double
The fourth power of the norm of a quaternion is the determinant of the corresponding matrix.int
double
int
hashCode()
int
intValue()
invert()
The multiplicative inverse.boolean
static boolean
isAbsolute
(Quaternion value) static boolean
isInfinite
(Quaternion value) static boolean
isNaN
(Quaternion value) boolean
isPure()
boolean
isReal()
static boolean
isReal
(Quaternion value) boolean
isSmall
(double comparedTo) static boolean
isSmall
(double comparedTo, Quaternion value) long
static Quaternion
makePolar
(double norm, double[] unit, double angle) static Quaternion
makeRotation
(Quaternion.RotationAxis axis, double angle) multiply
(double arg) multiply
(Quaternion arg) negate()
The additive inverse of this.double
norm()
this == this.signum().multiply(this.norm())
static Quaternion
of
(double i, double j, double k) static Quaternion
of
(double scalar, double i, double j, double k) power
(int power) Multiply by itselfpower
times.double
scalar()
signum()
this == this.signum().multiply(this.norm())
subtract
(double arg) subtract
(Quaternion arg) void
(package private) MatrixStore
<Double> toString()
toString
(NumberContext context) <T extends Mutate2D.ModifiableReceiver<Double>>
voidtransform
(T transformable) (package private) <T extends Mutate2D.ModifiableReceiver<Double>>
voidtransformVersor
(T transformable) double[]
unit()
static Quaternion
valueOf
(double value) static Quaternion
valueOf
(Comparable<?> number) vector()
versor()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.ojalgo.structure.Access1D
asCollectable1D, asKeyed1D, axpy, dot, select, supplyTo, toRawCopy1D
Methods inherited from interface org.ojalgo.structure.Access2D
asCollectable2D, asKeyed2D, byteValue, byteValue, byteValue, byteValue, columns, columns, columns, doubleValue, doubleValue, elements, floatValue, floatValue, floatValue, floatValue, intValue, intValue, intValue, intValue, longValue, longValue, longValue, longValue, nonzeros, rows, rows, rows, select, select, shortValue, shortValue, shortValue, shortValue, toRawCopy2D
Methods inherited from interface org.ojalgo.structure.Access2D.Collectable
collect
Methods inherited from interface org.ojalgo.type.NumberDefinition
booleanValue, byteValue, shortValue
Methods inherited from interface org.ojalgo.scalar.Scalar
add, dimensions, divide, multiply, rank, subtract, toPlainString
Methods inherited from interface org.ojalgo.scalar.SelfDeclaringScalar
add, divide, multiply, subtract
Methods inherited from interface org.ojalgo.structure.Structure2D
firstInColumn, firstInRow, getMaxDim, getMinDim, isEmpty, isFat, isScalar, isSquare, isTall, isVector, limitOfColumn, limitOfRow, size
Methods inherited from interface org.ojalgo.tensor.Tensor
components, isSameShape
-
Field Details
-
FACTORY
-
I
-
IJK
-
INFINITY
-
J
-
K
-
NaN
-
NEG
-
ONE
-
TWO
-
ZERO
-
ARGUMENT_TOLERANCE
private static final double ARGUMENT_TOLERANCE -
i
public final double i -
j
public final double j -
k
public final double k -
myPureForSure
private final boolean myPureForSure -
myRealForSure
private final boolean myRealForSure -
myScalar
private final double myScalar
-
-
Constructor Details
-
Quaternion
public Quaternion() -
Quaternion
private Quaternion(double scalar, double[] vector) -
Quaternion
private Quaternion(double[] vector) -
Quaternion
Quaternion(double scalar) -
Quaternion
Quaternion(double i, double j, double k) -
Quaternion
Quaternion(double scalar, double i, double j, double k)
-
-
Method Details
-
isAbsolute
-
isInfinite
-
isNaN
-
isReal
-
isSmall
-
makePolar
-
makeRotation
-
of
-
of
-
valueOf
-
valueOf
-
add
- Specified by:
add
in interfaceScalarOperation.Addition<Scalar<Quaternion>,
Quaternion> - Specified by:
add
in interfaceSelfDeclaringScalar<Quaternion>
- Returns:
this + scalarAddend
.
-
add
- Specified by:
add
in interfaceScalarOperation.Addition<Scalar<Quaternion>,
Quaternion> - Specified by:
add
in interfaceSelfDeclaringScalar<Quaternion>
- Returns:
this + scalarAddend
.
-
angle
public double angle() -
compareTo
First compares the real values. Only if they are equal will compare the imaginary part.- Specified by:
compareTo
in interfaceComparable<Quaternion>
-
conjugate
Description copied from interface:VectorSpace
This method will (most likely) be moved to some other interface in the future! Just have to figure out where it fits...
The conjugate transpose of a matrix and/or the conjugate of a scalar/field like ComplexNumber or Quaternion.
The conjugate transpose of a real matrix is simply its transpose.
- Specified by:
conjugate
in interfaceSelfDeclaringScalar<Quaternion>
- Specified by:
conjugate
in interfaceVectorSpace<Scalar<Quaternion>,
Quaternion>
-
count
public long count()Description copied from interface:Structure2D
count() == countRows() * countColumns()- Specified by:
count
in interfaceStructure1D
- Specified by:
count
in interfaceStructure2D
-
countColumns
public long countColumns()Description copied from interface:Structure2D
Only need to implement if the structure may contain more than Integer.MAX_VALUE elements.- Specified by:
countColumns
in interfaceStructure2D
- Returns:
- The number of columns
-
countRows
public long countRows()Description copied from interface:Structure2D
Only need to implement if the structure may contain more than Integer.MAX_VALUE elements.- Specified by:
countRows
in interfaceStructure2D
- Returns:
- The number of rows
-
divide
- Specified by:
divide
in interfaceScalarOperation.Division<Scalar<Quaternion>,
Quaternion> - Specified by:
divide
in interfaceSelfDeclaringScalar<Quaternion>
- Returns:
this / scalarDivisor
.
-
divide
Will calculatethis * reciprocal(arg)
which is not the same asreciprocal(arg) * this
.- Specified by:
divide
in interfaceScalarOperation.Division<Scalar<Quaternion>,
Quaternion> - Specified by:
divide
in interfaceSelfDeclaringScalar<Quaternion>
- Returns:
this / scalarDivisor
.
-
doubleValue
public double doubleValue()- Specified by:
doubleValue
in interfaceNumberDefinition
-
doubleValue
public double doubleValue(int index) - Specified by:
doubleValue
in interfaceAccess1D<Double>
- Specified by:
doubleValue
in interfaceAccess2D<Double>
-
doubleValue
public double doubleValue(int row, int col) Description copied from interface:Access2D
Extracts one element of this matrix as a double.- Specified by:
doubleValue
in interfaceAccess2D<Double>
- Parameters:
row
- A row index.col
- A column index.- Returns:
- One matrix element
-
enforce
- Specified by:
enforce
in interfaceNumberContext.Enforceable<Quaternion>
-
equals
-
floatValue
public float floatValue()- Specified by:
floatValue
in interfaceNumberDefinition
-
get
- Specified by:
get
in interfaceAccessScalar<Quaternion>
-
get
-
get
-
getColDim
public int getColDim()- Specified by:
getColDim
in interfaceStructure2D
- Returns:
- The number of columns
-
getDeterminant
public double getDeterminant()The fourth power of the norm of a quaternion is the determinant of the corresponding matrix. -
getPureVersor
- Returns:
- A normalised Quaternion with the real/scalar part "removed".
-
getRowDim
public int getRowDim()- Specified by:
getRowDim
in interfaceStructure2D
- Returns:
- The number of rows
-
getVectorLength
public double getVectorLength() -
hashCode
public int hashCode() -
intValue
public int intValue()- Specified by:
intValue
in interfaceNumberDefinition
-
invert
Description copied from interface:Group.Multiplicative
The multiplicative inverse.- Specified by:
invert
in interfaceGroup.Multiplicative<Scalar<Quaternion>>
- Specified by:
invert
in interfaceSelfDeclaringScalar<Quaternion>
- Returns:
IDENTITY / this
.
-
isAbsolute
public boolean isAbsolute()- Specified by:
isAbsolute
in interfaceScalar<Quaternion>
- Returns:
- true if this is equal to its own norm, modulus or absolute value (non-negative real part and no imaginary part); otherwise false.
- See Also:
-
isPure
public boolean isPure() -
isReal
public boolean isReal() -
isSmall
public boolean isSmall(double comparedTo) - Specified by:
isSmall
in interfaceNormedVectorSpace<Scalar<Quaternion>,
Quaternion> - Parameters:
comparedTo
- What to compare with- Returns:
- true if this is small compared to the magnitude of the input reference value.
-
longValue
public long longValue()- Specified by:
longValue
in interfaceNumberDefinition
-
multiply
- Specified by:
multiply
in interfaceScalarOperation.Multiplication<Scalar<Quaternion>,
Quaternion> - Specified by:
multiply
in interfaceSelfDeclaringScalar<Quaternion>
- Returns:
this * scalarMultiplicand
.
-
multiply
- Specified by:
multiply
in interfaceScalarOperation.Multiplication<Scalar<Quaternion>,
Quaternion> - Specified by:
multiply
in interfaceSelfDeclaringScalar<Quaternion>
- Returns:
this * multiplicand
.
-
negate
Description copied from interface:Group.Additive
The additive inverse of this.- Specified by:
negate
in interfaceGroup.Additive<Scalar<Quaternion>>
- Specified by:
negate
in interfaceSelfDeclaringScalar<Quaternion>
- Returns:
-this
.
-
norm
public double norm()Description copied from interface:NormedVectorSpace
this == this.signum().multiply(this.norm())
- Specified by:
norm
in interfaceNormedVectorSpace<Scalar<Quaternion>,
Quaternion> - Returns:
- The norm
-
power
Description copied from interface:Operation.Multiplication
Multiply by itselfpower
times.- Specified by:
power
in interfaceOperation.Multiplication<Scalar<Quaternion>>
- Specified by:
power
in interfaceSelfDeclaringScalar<Quaternion>
-
scalar
public double scalar() -
signum
Description copied from interface:NormedVectorSpace
this == this.signum().multiply(this.norm())
- Specified by:
signum
in interfaceNormedVectorSpace<Scalar<Quaternion>,
Quaternion> - Specified by:
signum
in interfaceSelfDeclaringScalar<Quaternion>
- Returns:
- A unit "vector"
-
subtract
- Specified by:
subtract
in interfaceScalarOperation.Subtraction<Scalar<Quaternion>,
Quaternion> - Specified by:
subtract
in interfaceSelfDeclaringScalar<Quaternion>
- Returns:
this - scalarSubtrahend
.
-
subtract
- Specified by:
subtract
in interfaceScalarOperation.Subtraction<Scalar<Quaternion>,
Quaternion> - Specified by:
subtract
in interfaceSelfDeclaringScalar<Quaternion>
- Returns:
this - scalarSubtrahend
.
-
supplyTo
- Specified by:
supplyTo
in interfaceAccess2D.Collectable<Double,
Mutate2D>
-
toBigDecimal
- Specified by:
toBigDecimal
in interfaceScalar<Quaternion>
-
toComplexMatrix
-
toMultiplicationMatrix
-
toMultiplicationVector
-
toRotationMatrix
-
toString
-
toString
- Specified by:
toString
in interfaceScalar<Quaternion>
-
transform
- Specified by:
transform
in interfaceTransformation2D<Double>
-
unit
public double[] unit() -
vector
-
versor
-
calculateSumOfSquaresAll
private double calculateSumOfSquaresAll() -
calculateSumOfSquaresVector
private double calculateSumOfSquaresVector() -
toRotationMatrixVersor
MatrixStore<Double> toRotationMatrixVersor() -
transformVersor
-