Class Matrix

java.lang.Object
hoverball.math.Matrix

public final class Matrix
extends java.lang.Object
Die Klasse Matrix repräsentiert eine reelle 3 x 3-Matrix.

Im Folgenden bedeuten:
    A, B, M  -  Matrizen
    a, b, c  -  Vektoren (als Spaltenvektoren)
    x, y, z  -  reelle Zahlen (als Koordinaten)
    v  -  Vektor
    r  -  reelle Zahl
    a ("alpha")  -  reelle Zahl (als Winkel)
    x, y, z  -  die Einheitsvektoren
    M  -  die Matrix des Matrix-Objekts selbst

Beachte: Anders als bei der Standard-Notation der Mathematik wird die Verknüpfung von Matrizen hier von links nach rechts gelesen. In Hoverball heißt es für einen Vektor v, auf den die Matrix A und anschließend die Matrix B angewendet werden soll, also v A B statt B A v.

Operator Overloading für Groovy, Scala, Kotlin und Jython wird unterstützt.

  • Field Summary

    Fields 
    Modifier and Type Field Description
    Vector a
    Erster Spaltenvektor der Matrix.
    Vector b
    Zweiter Spaltenvektor der Matrix.
    Vector c
    Dritter Spaltenvektor der Matrix.
  • Constructor Summary

    Constructors 
    Constructor Description
    Matrix()
    Erzeugt eine Einheitsmatrix.
    Matrix​(double r)
    Erzeugt ein Vielfaches der Einheitsmatrix.
    Matrix​(double ax, double ay, double az, double bx, double by, double bz, double cx, double cy, double cz)
    Erzeugt eine Matrix mit den Koordinaten ((ax,ay,az), (bx,by,bz), (cx,cy,cz)).
    Matrix​(Matrix M)
    Erzeugt eine Matrix gleich einer anderen Matrix.
    Matrix​(Vector a, Vector b, Vector c)
    Erzeugt eine Matrix mit den Spaltenvektoren (a,b,c).
  • Method Summary

    Modifier and Type Method Description
    Matrix add​(Matrix B)
    Addiert eine Matrix  [ M = M + B ].
    static Matrix add​(Matrix A, Matrix B)
    Addiert zwei Matrizen  [ = A + B ].
    Matrix conj​(Matrix B)
    Konjugiert mit einer Matrix  [ M = B^ M B ].
    static Matrix conj​(Matrix A, Matrix B)
    Konjugiert eine Matrix mit einer Matrix  [ = B^ A B ].
    double det()
    Berechnet die Determinante  [ = det M ].
    boolean equals​(java.lang.Object M)
    Vergleicht mit einer Matrix  [ M = M ?
    int hashCode()
    Berechnet den Hash-Code  [ = #### ].
    Matrix inv()
    Invertiert die Matrix  [ M = M^ ].
    static Matrix inv​(Matrix M)
    Berechnet die inverse Matrix  [ = M^ ].
    Matrix mul​(double r)
    Multipliziert mit einer reellen Zahl  [ M = M r ].
    Matrix mul​(Matrix B)
    Entspricht der Methode mulR(Matrix).
    static Matrix mul​(Matrix M, double r)
    Multipliziert eine Matrix mit einer reellen Zahl  [ = M r ].
    static Matrix mul​(Matrix A, Matrix B)
    Multipliziert zwei Matrizen  [ = A B ].
    Matrix mulL​(Matrix A)
    Multipliziert mit einer Matrix von links  [ M = A M ].
    Matrix mulR​(Matrix B)
    Multipliziert mit einer Matrix von rechts  [ M = M B ].
    Matrix neg()
    Negiert die Matrix  [ M = -M ].
    static Matrix neg​(Matrix M)
    Berechnet die negierte Matrix  [ = -M ].
    static Matrix rot​(Vector v, double alpha)
    Berechnet eine Drehmatrix um eine beliebige Drehachse  [ = D (v,a) ].
    static Matrix rotX​(double alpha)
    Berechnet eine Drehmatrix um die x-Achse  [ = D (x,a) ].
    static Matrix rotY​(double alpha)
    Berechnet eine Drehmatrix um die y-Achse  [ = D (y,a) ].
    static Matrix rotZ​(double alpha)
    Berechnet eine Drehmatrix um die z-Achse  [ = D (z,a) ].
    Matrix sub​(Matrix B)
    Subtrahiert eine Matrix  [ M = M - B ].
    static Matrix sub​(Matrix A, Matrix B)
    Subtrahiert zwei Matrizen  [ = A - B ].
    java.lang.String toString()
    String-Repräsentation  [ = "..." ].
    Matrix trans()
    Transponiert die Matrix  [ M = M ].
    static Matrix trans​(Matrix M)
    Berechnet die transponierte Matrix  [ = M ].
    boolean zero()
    Testet auf null  [ M = 0 ?

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • a

      public final Vector a
      Erster Spaltenvektor der Matrix.
    • b

      public final Vector b
      Zweiter Spaltenvektor der Matrix.
    • c

      public final Vector c
      Dritter Spaltenvektor der Matrix.
  • Constructor Details

    • Matrix

      public Matrix()
      Erzeugt eine Einheitsmatrix.
    • Matrix

      public Matrix​(double r)
      Erzeugt ein Vielfaches der Einheitsmatrix.
      Parameters:
      r - Faktor
    • Matrix

      public Matrix​(double ax, double ay, double az, double bx, double by, double bz, double cx, double cy, double cz)
      Erzeugt eine Matrix mit den Koordinaten ((ax,ay,az), (bx,by,bz), (cx,cy,cz)).
      Parameters:
      ax - x-Koordinate des ersten Spaltenvektors
      ay - y-Koordinate des ersten Spaltenvektors
      az - z-Koordinate des ersten Spaltenvektors
      bx - x-Koordinate des zweiten Spaltenvektors
      by - y-Koordinate des zweiten Spaltenvektors
      bz - z-Koordinate des zweiten Spaltenvektors
      cx - x-Koordinate des dritten Spaltenvektors
      cy - y-Koordinate des dritten Spaltenvektors
      cz - z-Koordinate des dritten Spaltenvektors
    • Matrix

      public Matrix​(Vector a, Vector b, Vector c)
      Erzeugt eine Matrix mit den Spaltenvektoren (a,b,c).
      Parameters:
      a - erster Spaltenvektor
      b - zweiter Spaltenvektor
      c - dritter Spaltenvektor
    • Matrix

      public Matrix​(Matrix M)
      Erzeugt eine Matrix gleich einer anderen Matrix.
      Parameters:
      M - zu kopierende Matrix
  • Method Details

    • hashCode

      public int hashCode()
      Berechnet den Hash-Code  [ = #### ].
      Overrides:
      hashCode in class java.lang.Object
      Returns:
      den Hash-Code
    • toString

      public java.lang.String toString()
      String-Repräsentation  [ = "..." ].
      Overrides:
      toString in class java.lang.Object
      Returns:
      den String
    • equals

      public boolean equals​(java.lang.Object M)
      Vergleicht mit einer Matrix  [ M = M ? ].
      Overrides:
      equals in class java.lang.Object
      Parameters:
      M - Matrix
      Returns:
      die Gleichheit
    • add

      public final Matrix add​(Matrix B)
      Addiert eine Matrix  [ M = M + B ].
      Parameters:
      B - Matrix
      Returns:
      this
    • sub

      public final Matrix sub​(Matrix B)
      Subtrahiert eine Matrix  [ M = M - B ].
      Parameters:
      B - Matrix
      Returns:
      this
    • mul

      public final Matrix mul​(double r)
      Multipliziert mit einer reellen Zahl  [ M = M r ].
      Parameters:
      r - reelle Zahl
      Returns:
      this
    • mulL

      public final Matrix mulL​(Matrix A)
      Multipliziert mit einer Matrix von links  [ M = A M ].
      Parameters:
      A - Matrix
      Returns:
      this
    • mulR

      public final Matrix mulR​(Matrix B)
      Multipliziert mit einer Matrix von rechts  [ M = M B ].
      Parameters:
      B - Matrix
      Returns:
      this
    • mul

      public final Matrix mul​(Matrix B)
      Entspricht der Methode mulR(Matrix).
      Parameters:
      B - Matrix
      Returns:
      this
    • conj

      public final Matrix conj​(Matrix B)
      Konjugiert mit einer Matrix  [ M = B^ M B ].
      Parameters:
      B - Matrix
      Returns:
      this
    • inv

      public final Matrix inv()
      Invertiert die Matrix  [ M = M^ ].
      Returns:
      this
    • neg

      public final Matrix neg()
      Negiert die Matrix  [ M = -M ].
      Returns:
      this
    • trans

      public final Matrix trans()
      Transponiert die Matrix  [ M = M ].
      Returns:
      this
    • zero

      public final boolean zero()
      Testet auf null  [ M = 0 ? ].
      Returns:
      true, falls diese Matrix gleich (0)
    • det

      public final double det()
      Berechnet die Determinante  [ = det M ].
      Returns:
      das Argument
    • add

      public static final Matrix add​(Matrix A, Matrix B)
      Addiert zwei Matrizen  [ = A + B ].
      Parameters:
      A - Matrix
      B - Matrix
      Returns:
      die Summe
    • sub

      public static final Matrix sub​(Matrix A, Matrix B)
      Subtrahiert zwei Matrizen  [ = A - B ].
      Parameters:
      A - Matrix
      B - Matrix
      Returns:
      die Differenz
    • neg

      public static final Matrix neg​(Matrix M)
      Berechnet die negierte Matrix  [ = -M ].
      Parameters:
      M - Matrix
      Returns:
      die negierte Matrix
    • inv

      public static final Matrix inv​(Matrix M)
      Berechnet die inverse Matrix  [ = M^ ].
      Parameters:
      M - Matrix
      Returns:
      die Inverse
    • trans

      public static final Matrix trans​(Matrix M)
      Berechnet die transponierte Matrix  [ = M ].
      Parameters:
      M - Matrix
      Returns:
      die Transponierte
    • mul

      public static final Matrix mul​(Matrix M, double r)
      Multipliziert eine Matrix mit einer reellen Zahl  [ = M r ].
      Parameters:
      M - Matrix
      r - reelle Zahl
      Returns:
      das Produkt
    • mul

      public static final Matrix mul​(Matrix A, Matrix B)
      Multipliziert zwei Matrizen  [ = A B ].
      Parameters:
      A - Matrix
      B - Matrix
      Returns:
      das Produkt
    • conj

      public static final Matrix conj​(Matrix A, Matrix B)
      Konjugiert eine Matrix mit einer Matrix  [ = B^ A B ].
      Parameters:
      A - Matrix
      B - Matrix
      Returns:
      die Konjugation
    • rotX

      public static final Matrix rotX​(double alpha)
      Berechnet eine Drehmatrix um die x-Achse  [ = D (x,a) ].
      Parameters:
      alpha - Winkel
      Returns:
      die Drehmatrix
    • rotY

      public static final Matrix rotY​(double alpha)
      Berechnet eine Drehmatrix um die y-Achse  [ = D (y,a) ].
      Parameters:
      alpha - Winkel
      Returns:
      die Drehmatrix
    • rotZ

      public static final Matrix rotZ​(double alpha)
      Berechnet eine Drehmatrix um die z-Achse  [ = D (z,a) ].
      Parameters:
      alpha - Winkel
      Returns:
      die Drehmatrix
    • rot

      public static final Matrix rot​(Vector v, double alpha)
      Berechnet eine Drehmatrix um eine beliebige Drehachse  [ = D (v,a) ].
      Parameters:
      v - Vektor, an dem gedreht wird
      alpha - Winkel
      Returns:
      die Drehmatrix