core.math
Class Mat2

java.lang.Object
  extended bycore.math.Mat2

public class Mat2
extends java.lang.Object

Mat2 is a 2x2 matrix = < [[a, b], [c, d]] > This class stores and operates on a 2x2 matrix. Methods that begin with a capital letter modify "this", while methods that begin with a lowercase letter create a new Mat2 to store the result.


Field Summary
 double a
          a,b,c,d are the components of the matrix
 double b
          a,b,c,d are the components of the matrix
 double c
          a,b,c,d are the components of the matrix
 double d
          a,b,c,d are the components of the matrix
static Mat2 Ident
          Do not modify Ident = the identity matrix
static Mat2 Invalid
          Do not modify Invalid = an invalid Mat2
static double tolerance
          Do not modify tolerance is the per-component zero-value maximium
static Mat2 Zero
          Do not modify Zero = the zero matrix
 
Constructor Summary
Mat2()
          Constructs a new Mat2 = [[1, 0], [0, 1]]
Mat2(double a, double b, double c, double d)
          Constructs a new Mat2 = [[a, b], [c, d]]
Mat2(Mat2 m)
          Constructs a new Mat2 = "m"
 
Method Summary
 Mat2 add(Mat2 m)
          Returns: a new Mat2 that is the sum of "this" and "m"
 Mat2 Add(Mat2 m)
          Adds "m" to "this" Returns: resulting "this"
 Mat2 addscaled(Mat2 m, double s)
          Returns: a new Mat2 that is the sum of "this" and "s*m"
 Mat2 AddScaled(Mat2 m, double s)
          Adds "s*m" to "this" Returns: resulting "this"
 double det()
          Returns: the determinant of "this"
 double dot(Mat2 m)
          Returns: the dot product of "this" and "m"
 boolean equals(Mat2 m)
          Returns: true if "this" equals "m", false otherwise
 double getScale()
          Returns: the geometric mean of the magnitude of the x- and y-axes of "this" used as a left-multiplying linear transform
 Mat2 invert()
          Returns: a new Mat2 that is the inverse of "this" Requires: "this" is not singular
 Mat2 Invert()
          Inverts "this" Returns: resulting "this" Requires: "this" is not singular
 boolean isOrthogonal()
           
 boolean isOrthoNormal()
          Returns: true if the x- and y-axes of "this" as a left-multiplying linear transform are orthonormal, false otherwise
 boolean isOrthoScaled()
          Returns: true if the x- and y-axes of "this" as a left-multiplying linear transform are orthogonal and of equal magnitude, else false
 boolean isZero()
          Returns: true if "this" is zero, false otherwise
 Vec2 lmul(Vec2 v)
          Returns: a new Vec2 that is "v*this"
 Mat2 mul(Mat2 m)
          Returns: a new Mat2 that is "m*this"
 Mat2 Mul(Mat2 m)
          Multiplies "this" to the left by "m" Returns: resulting "this"
 Vec2 mul(Vec2 v)
          Returns: a new Vec2 that is "this*v"
 Mat2 neg()
          Returns: a new Mat2 that is the opposite of "this"
 Mat2 Neg()
          Negates "this" Returns: resulting "this"
 Mat2 rmul(Mat2 m)
          Returns: a new Mat2 that is "this*m"
 Mat2 RMul(Mat2 m)
          Multiplies "this" to the right by "m" Returns: resulting "this"
 Mat2 scale(double s)
          Returns: a new Mat2 that is "s*this"
 Mat2 Scale(double s)
          Scales "this" by "s" Returns: resulting "this"
 Mat2 Set(double a, double b, double c, double d)
          Sets "this" to [[a, b], [c, d]].
 Mat2 Set(Mat2 m)
          Sets the value of "this" to that of "m" Returns: resulting "this"
 Mat2 SetIdent()
          Sets "this" to the identity matrix.
 Mat2 SetZero()
          Sets "this" to zero.
 Mat2 sub(Mat2 m)
          Returns: a new Mat2 that is the difference between "this" and "m"
 Mat2 Sub(Mat2 m)
          Subtracts "m" from "this" Returns: resulting "this"
 Vec2 xaxis()
          Returns: a new Vec2 containing the x-axis of "this" when it is used as a linear transform left-multiplying a vector
 Vec2 yaxis()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

a

public double a
a,b,c,d are the components of the matrix


b

public double b
a,b,c,d are the components of the matrix


c

public double c
a,b,c,d are the components of the matrix


d

public double d
a,b,c,d are the components of the matrix


Zero

public static Mat2 Zero
Do not modify Zero = the zero matrix


Ident

public static Mat2 Ident
Do not modify Ident = the identity matrix


Invalid

public static Mat2 Invalid
Do not modify Invalid = an invalid Mat2


tolerance

public static double tolerance
Do not modify tolerance is the per-component zero-value maximium

Constructor Detail

Mat2

public Mat2()
Constructs a new Mat2 = [[1, 0], [0, 1]]


Mat2

public Mat2(Mat2 m)
Constructs a new Mat2 = "m"


Mat2

public Mat2(double a,
            double b,
            double c,
            double d)
Constructs a new Mat2 = [[a, b], [c, d]]

Method Detail

Set

public Mat2 Set(Mat2 m)
Sets the value of "this" to that of "m" Returns: resulting "this"


Set

public Mat2 Set(double a,
                double b,
                double c,
                double d)
Sets "this" to [[a, b], [c, d]]. Returns: resulting "this"


SetZero

public Mat2 SetZero()
Sets "this" to zero. Returns: resulting "this"


SetIdent

public Mat2 SetIdent()
Sets "this" to the identity matrix. Returns" resulting "this"


isZero

public boolean isZero()
Returns: true if "this" is zero, false otherwise


equals

public boolean equals(Mat2 m)
Returns: true if "this" equals "m", false otherwise


Add

public Mat2 Add(Mat2 m)
Adds "m" to "this" Returns: resulting "this"


add

public Mat2 add(Mat2 m)
Returns: a new Mat2 that is the sum of "this" and "m"


AddScaled

public Mat2 AddScaled(Mat2 m,
                      double s)
Adds "s*m" to "this" Returns: resulting "this"


addscaled

public Mat2 addscaled(Mat2 m,
                      double s)
Returns: a new Mat2 that is the sum of "this" and "s*m"


Sub

public Mat2 Sub(Mat2 m)
Subtracts "m" from "this" Returns: resulting "this"


sub

public Mat2 sub(Mat2 m)
Returns: a new Mat2 that is the difference between "this" and "m"


Neg

public Mat2 Neg()
Negates "this" Returns: resulting "this"


neg

public Mat2 neg()
Returns: a new Mat2 that is the opposite of "this"


dot

public double dot(Mat2 m)
Returns: the dot product of "this" and "m"


Scale

public Mat2 Scale(double s)
Scales "this" by "s" Returns: resulting "this"


scale

public Mat2 scale(double s)
Returns: a new Mat2 that is "s*this"


Mul

public Mat2 Mul(Mat2 m)
Multiplies "this" to the left by "m" Returns: resulting "this"


mul

public Mat2 mul(Mat2 m)
Returns: a new Mat2 that is "m*this"


RMul

public Mat2 RMul(Mat2 m)
Multiplies "this" to the right by "m" Returns: resulting "this"


rmul

public Mat2 rmul(Mat2 m)
Returns: a new Mat2 that is "this*m"


mul

public Vec2 mul(Vec2 v)
Returns: a new Vec2 that is "this*v"


lmul

public Vec2 lmul(Vec2 v)
Returns: a new Vec2 that is "v*this"


det

public double det()
Returns: the determinant of "this"


Invert

public Mat2 Invert()
Inverts "this" Returns: resulting "this" Requires: "this" is not singular


invert

public Mat2 invert()
Returns: a new Mat2 that is the inverse of "this" Requires: "this" is not singular


xaxis

public Vec2 xaxis()
Returns: a new Vec2 containing the x-axis of "this" when it is used as a linear transform left-multiplying a vector


yaxis

public Vec2 yaxis()

isOrthogonal

public boolean isOrthogonal()

isOrthoNormal

public boolean isOrthoNormal()
Returns: true if the x- and y-axes of "this" as a left-multiplying linear transform are orthonormal, false otherwise


isOrthoScaled

public boolean isOrthoScaled()
Returns: true if the x- and y-axes of "this" as a left-multiplying linear transform are orthogonal and of equal magnitude, else false


getScale

public double getScale()
Returns: the geometric mean of the magnitude of the x- and y-axes of "this" used as a left-multiplying linear transform