Class Quaternion

java.lang.Object
org.episteme.core.mathematics.numbers.complex.Quaternion
All Implemented Interfaces:
AbelianGroup<Quaternion>, AbelianMonoid<Quaternion>, Group<Quaternion>, Magma<Quaternion>, Monoid<Quaternion>, Field<Quaternion>, Ring<Quaternion>, Semiring<Quaternion>, Set<Quaternion>

public final class Quaternion extends Object implements Field<Quaternion>
Represents a Quaternion number (H).

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 Details

  • Constructor Details

    • Quaternion

      public Quaternion(Real a, Real b, Real c, Real d)
    • Quaternion

      public Quaternion(double a, double b, double c, double d)
  • Method Details

    • of

      public static Quaternion of(Real a, Real b, Real c, Real d)
    • of

      public static Quaternion of(double a, double b, double c, double d)
    • of

      public static Quaternion of(Real real)
    • of

      public static Quaternion of(double real)
    • getReal

      public Real getReal()
    • getI

      public Real getI()
    • getJ

      public Real getJ()
    • getK

      public Real getK()
    • add

      public Quaternion add(Quaternion other)
    • subtract

      public Quaternion subtract(Quaternion other)
    • multiply

      public Quaternion multiply(Quaternion other)
    • multiply

      public Quaternion multiply(Real scalar)
    • multiply

      public Quaternion multiply(double scalar)
    • conjugate

      public Quaternion conjugate()
    • normSquared

      public Real normSquared()
    • norm

      public Real norm()
    • inverse

      public Quaternion inverse()
    • negate

      public Quaternion negate()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • operate

      public Quaternion operate(Quaternion left, Quaternion right)
      Description copied from interface: Magma
      Performs 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:
      operate in interface Magma<Quaternion>
      Parameters:
      left - the first operand
      right - the second operand
      Returns:
      the result of a ∗ b
      See Also:
    • zero

      public Quaternion zero()
      Description copied from interface: AbelianMonoid
      Returns the additive identity (zero element).

      Delegates to AbelianMonoid.identity().

      Specified by:
      zero in interface AbelianMonoid<Quaternion>
      Returns:
      the zero element
    • one

      public Quaternion one()
      Description copied from interface: Semiring
      Returns the multiplicative identity (one element).

      Satisfies: 1 × a = a × 1 = a for all elements a.

      Specified by:
      one in interface Semiring<Quaternion>
      Returns:
      the multiplicative identity
    • negate

      public Quaternion negate(Quaternion element)
      Description copied from interface: AbelianGroup
      Returns the additive inverse (negation) of an element.

      Satisfies: a + (-a) = (-a) + a = 0

      Specified by:
      negate in interface AbelianGroup<Quaternion>
      Parameters:
      element - the element to negate
      Returns:
      -element
      See Also:
    • inverse

      public Quaternion inverse(Quaternion element)
      Description copied from interface: Field
      Returns 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:
      inverse in interface Field<Quaternion>
      Specified by:
      inverse in interface Group<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: Field
      Fields always have commutative multiplication.
      Specified by:
      isMultiplicationCommutative in interface Field<Quaternion>
      Specified by:
      isMultiplicationCommutative in interface Semiring<Quaternion>
      Returns:
      always true
    • characteristic

      public int characteristic()
      Description copied from interface: Field
      Returns 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:
      characteristic in interface Field<Quaternion>
      Returns:
      the characteristic (0 for infinite fields, p for finite fields)
    • description

      public String description()
      Description copied from interface: Set
      Returns a human-readable description of this set.

      Examples:

      • "ℝ (Real Numbers)"
      • "ℤ/12ℤ (Integers modulo 12)"
      • "{1, 2, 3, 4, 5}"

      Specified by:
      description in interface Set<Quaternion>
      Returns:
      a description of this set
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Set
      Returns true if 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:
      isEmpty in interface Set<Quaternion>
      Returns:
      true if this set is empty
    • contains

      public boolean contains(Quaternion element)
      Description copied from interface: Set
      Tests whether this set contains the specified element.

      This is the fundamental operation of a set - membership testing.

      Specified by:
      contains in interface Set<Quaternion>
      Parameters:
      element - the element to test for membership
      Returns:
      true if this set contains the element, false otherwise
      See Also:
    • add

      public Quaternion add(Quaternion a, Quaternion b)
      Description copied from interface: AbelianMonoid
      Returns the sum of two elements (additive notation).

      Delegates to Magma.operate(Object, Object).

      Specified by:
      add in interface AbelianMonoid<Quaternion>
      Parameters:
      a - the first addend
      b - the second addend
      Returns:
      a + b
    • multiply

      public Quaternion multiply(Quaternion a, Quaternion b)
      Description copied from interface: Semiring
      Returns the product of two elements.

      Multiplication must be associative and distribute over addition.

      Specified by:
      multiply in interface Semiring<Quaternion>
      Parameters:
      a - the first factor
      b - the second factor
      Returns:
      a × b