Class Quaternion
- All Implemented Interfaces:
AbelianGroup<Quaternion>, AbelianMonoid<Quaternion>, Group<Quaternion>, Magma<Quaternion>, Monoid<Quaternion>, Field<Quaternion>, Ring<Quaternion>, Semiring<Quaternion>, Set<Quaternion>
q = a + bi + cj + dk Quaternions form a non-commutative division ring (skew field).
* @author Silvere Martin-Michiellot- Since:
- 1.0
- Author:
- Gemini AI (Google DeepMind)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Quaternionstatic final Quaternionstatic final Quaternionstatic final Quaternionstatic final Quaternion -
Constructor Summary
ConstructorsConstructorDescriptionQuaternion(double a, double b, double c, double d) Quaternion(Real a, Real b, Real c, Real d) -
Method Summary
Modifier and TypeMethodDescriptionadd(Quaternion other) add(Quaternion a, Quaternion b) Returns the sum of two elements (additive notation).intReturns the characteristic of this field.booleancontains(Quaternion element) Tests whether this set contains the specified element.Returns a human-readable description of this set.booleangetI()getJ()getK()getReal()inthashCode()inverse()inverse(Quaternion element) Returns the multiplicative inverse of a non-zero element.booleanisEmpty()Returnstrueif this set contains no elements.booleanFields always have commutative multiplication.multiply(double scalar) multiply(Quaternion other) multiply(Quaternion a, Quaternion b) Returns the product of two elements.negate()negate(Quaternion element) Returns the additive inverse (negation) of an element.norm()static Quaternionof(double real) static Quaternionof(double a, double b, double c, double d) static Quaternionstatic Quaternionone()Returns the multiplicative identity (one element).operate(Quaternion left, Quaternion right) Performs the binary operation on two elements.subtract(Quaternion other) toString()zero()Returns the additive identity (zero element).Methods inherited from interface AbelianGroup
isCommutative, subtractMethods inherited from interface AbelianMonoid
identity, isCommutativeMethods inherited from interface Monoid
isAssociative
-
Field Details
-
ZERO
-
ONE
-
I
-
J
-
K
-
-
Constructor Details
-
Quaternion
-
Quaternion
public Quaternion(double a, double b, double c, double d)
-
-
Method Details
-
of
-
of
-
of
-
of
-
getReal
-
getI
-
getJ
-
getK
-
add
-
subtract
-
multiply
-
multiply
-
multiply
-
conjugate
-
normSquared
-
norm
-
inverse
-
negate
-
toString
-
equals
-
hashCode
-
operate
Description copied from interface:MagmaPerforms the binary operation on two elements.This is the fundamental operation of a magma. The result must be an element of this magma (closure property).
Properties: None required (not necessarily associative or commutative)
- Specified by:
operatein interfaceMagma<Quaternion>- Parameters:
left- the first operandright- the second operand- Returns:
- the result of a ∗ b
- See Also:
-
zero
Description copied from interface:AbelianMonoidReturns the additive identity (zero element).Delegates to
AbelianMonoid.identity().- Specified by:
zeroin interfaceAbelianMonoid<Quaternion>- Returns:
- the zero element
-
one
Description copied from interface:SemiringReturns the multiplicative identity (one element).Satisfies: 1 × a = a × 1 = a for all elements a.
- Specified by:
onein interfaceSemiring<Quaternion>- Returns:
- the multiplicative identity
-
negate
Description copied from interface:AbelianGroupReturns the additive inverse (negation) of an element.Satisfies: a + (-a) = (-a) + a = 0
- Specified by:
negatein interfaceAbelianGroup<Quaternion>- Parameters:
element- the element to negate- Returns:
- -element
- See Also:
-
inverse
Description copied from interface:FieldReturns the multiplicative inverse of a non-zero element.For element a ≠0, returns a⻹ such that: a × a⻹ = a⻹ × a = 1
Examples:
- In ℚ: inverse(2/3) = 3/2
- In â„Â: inverse(5.0) = 0.2
- In â„‚: inverse(3+4i) = (3-4i)/25
- Specified by:
inversein interfaceField<Quaternion>- Specified by:
inversein interfaceGroup<Quaternion>- Parameters:
element- the element to invert (must be non-zero)- Returns:
- the multiplicative inverse
- See Also:
-
isMultiplicationCommutative
public boolean isMultiplicationCommutative()Description copied from interface:FieldFields always have commutative multiplication.- Specified by:
isMultiplicationCommutativein interfaceField<Quaternion>- Specified by:
isMultiplicationCommutativein interfaceSemiring<Quaternion>- Returns:
- always
true
-
characteristic
public int characteristic()Description copied from interface:FieldReturns the characteristic of this field.The characteristic is the smallest positive integer n such that:
1 + 1 + ... + 1 (n times) = 0
If no such n exists, the characteristic is 0.Examples:
- char(ℚ) = char(â„Â) = char(â„‚) = 0
- char(ðÂâ€Â½Ã¢â€šÅ¡) = p (for prime p)
- Specified by:
characteristicin interfaceField<Quaternion>- Returns:
- the characteristic (0 for infinite fields, p for finite fields)
-
description
Description copied from interface:SetReturns a human-readable description of this set.Examples:
- "â„ (Real Numbers)"
- "ℤ/12ℤ (Integers modulo 12)"
- "{1, 2, 3, 4, 5}"
- Specified by:
descriptionin interfaceSet<Quaternion>- Returns:
- a description of this set
-
isEmpty
public boolean isEmpty()Description copied from interface:SetReturnstrueif this set contains no elements.The empty set (∅) is a fundamental concept in set theory. It is the unique set containing no elements.
- Specified by:
isEmptyin interfaceSet<Quaternion>- Returns:
trueif this set is empty
-
contains
Description copied from interface:SetTests whether this set contains the specified element.This is the fundamental operation of a set - membership testing.
- Specified by:
containsin interfaceSet<Quaternion>- Parameters:
element- the element to test for membership- Returns:
trueif this set contains the element,falseotherwise- See Also:
-
add
Description copied from interface:AbelianMonoidReturns the sum of two elements (additive notation).Delegates to
Magma.operate(Object, Object).- Specified by:
addin interfaceAbelianMonoid<Quaternion>- Parameters:
a- the first addendb- the second addend- Returns:
- a + b
-
multiply
Description copied from interface:SemiringReturns the product of two elements.Multiplication must be associative and distribute over addition.
- Specified by:
multiplyin interfaceSemiring<Quaternion>- Parameters:
a- the first factorb- the second factor- Returns:
- a × b
-