Class Matrix

java.lang.Object
org.shredzone.commons.suncalc.util.Matrix

public class Matrix extends Object
A three dimensional matrix.

Objects are immutable and threadsafe.

  • Method Details

    • identity

      public static Matrix identity()
      Creates an identity matrix.
      Returns:
      Identity Matrix
    • rotateX

      public static Matrix rotateX(double angle)
      Creates a matrix that rotates a vector by the given angle at the X axis.
      Parameters:
      angle - angle, in radians
      Returns:
      Rotation Matrix
    • rotateY

      public static Matrix rotateY(double angle)
      Creates a matrix that rotates a vector by the given angle at the Y axis.
      Parameters:
      angle - angle, in radians
      Returns:
      Rotation Matrix
    • rotateZ

      public static Matrix rotateZ(double angle)
      Creates a matrix that rotates a vector by the given angle at the Z axis.
      Parameters:
      angle - angle, in radians
      Returns:
      Rotation Matrix
    • transpose

      public Matrix transpose()
      Transposes this matrix.
      Returns:
      Matrix that is a transposition of this matrix.
    • negate

      public Matrix negate()
      Negates this matrix.
      Returns:
      Matrix that is a negation of this matrix.
    • add

      public Matrix add(Matrix right)
      Adds a matrix to this matrix.
      Parameters:
      right - Matrix to add
      Returns:
      Matrix that is a sum of both matrices
    • subtract

      public Matrix subtract(Matrix right)
      Subtracts a matrix from this matrix.
      Parameters:
      right - Matrix to subtract
      Returns:
      Matrix that is the difference of both matrices
    • multiply

      public Matrix multiply(Matrix right)
      Multiplies two matrices.
      Parameters:
      right - Matrix to multiply with
      Returns:
      Matrix that is the product of both matrices
    • multiply

      public Matrix multiply(double scalar)
      Performs a scalar multiplication.
      Parameters:
      scalar - Scalar to multiply with
      Returns:
      Matrix that is the scalar product
    • multiply

      public Vector multiply(Vector right)
      Applies this matrix to a Vector.
      Parameters:
      right - Vector to multiply with
      Returns:
      Vector that is the product of this matrix and the given vector
    • get

      public double get(int r, int c)
      Gets a value from the matrix.
      Parameters:
      r - Row number (0..2)
      c - Column number (0..2)
      Returns:
      Value at that position
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object