# Class M4

java.lang.Object
javajs.util.M34
javajs.util.M4

Direct Known Subclasses:
  `SymmetryOperation`

public class M4 extends M34
A single precision floating point 4 by 4 matrix.

Author:
  Kenji hiranabe additions by Bob Hanson hansonr@stolaf.edu 9/30/2012 for unique constructor and method names for the optimization of compiled JavaScript using Java2Script

## Field Summary

Fields
Modifier and Type
Field
Description
`float`
`m03`
The fourth element of the first row.
`float`
`m13`
The fourth element of the second row.
`float`
`m23`
The fourth element of the third row.
`float`
`m30`
The first element of the fourth row.
`float`
`m31`
The second element of the fourth row.
`float`
`m32`
The third element of the fourth row.
`float`
`m33`
The fourth element of the fourth row.

### Fields inherited from class M34

`m00, m01, m02, m10, m11, m12, m20, m21, m22`

## Constructor Summary

Constructors
Constructor
Description
`M4()`
all zeros

## Method Summary

Modifier and Type
Method
Description
`void`
`add(T3 pt)`
add to translation
`float`
`determinant4()`
Computes the determinant of this matrix.
`boolean`
`equals(Object o)`
Returns true if the Object o is of type Matrix4f and all of the data members of t1 are equal to the corresponding data members in this Matrix4f.
`void`
`getColumn(int column, float[] v)`
Copies the matrix values in the specified column into the array parameter.
`float`
`getElement(int row, int col)`
Retrieves the value at the specified row and column of this matrix.
`void`
`getRotationScale(M3 m1)`
Gets the upper 3x3 values of this matrix and places them into the matrix m1.
`void`
`getRow(int row, float[] v)`
Copies the matrix values in the specified row into the array parameter.
`void`
`getTranslation(T3 trans)`
Retrieves the translational components of this matrix.
`int`
`hashCode()`
Returns a hash number based on the data values in this object.
`M4`
`invert()`
Sets the value of this matrix to its inverse.
`void`
`mul(M4 m1)`
Sets the value of this matrix to the result of multiplying itself with matrix m1.
`void`
`mul2(M4 m1, M4 m2)`
Sets the value of this matrix to the result of multiplying the two argument matrices together.
`static M4`
`newA16(float[] v)`
Constructs and initializes a Matrix4f from the specified 16 element array.
`static M4`
`newM4(M4 m1)`
Constructs a new matrix with the same values as the Matrix4f parameter.
`static M4`
`newMV(M3 m1, T3 t)`
Constructs and initializes a Matrix4f from the rotation matrix and translation.
`void`
`rotTrans(T3 point)`
Transforms the point parameter with this Matrix4f and places the result back into point.
`T3`
`rotTrans2(T3 point, T3 pointOut)`
Transforms the point parameter with this Matrix4f and places the result into pointOut.
`M4`
`round(float f)`
`void`
`scale(float scalar)`
Multiplies each element of this matrix by a scalar.
`void`
`setA(float[] m)`
Sets the values in this Matrix4f equal to the row-major array parameter (ie, the first four elements of the array will be copied into the first row of this matrix, etc.).
`M4`
`setAsXYRotation(float angle)`
Sets the value of this matrix to a rotation matrix about the w axis by the passed angle.
`M4`
`setAsXZRotation(float angle)`
Sets the value of this matrix to a rotation matrix about the w axis by the passed angle.
`M4`
`setAsYZRotation(float angle)`
Sets the value of this matrix to a rotation matrix about the w axis by the passed angle.
`void`
`setColumn4(int column, float x, float y, float z, float w)`
Sets the specified column of this matrix4f to the four values provided.
`void`
`setColumnA(int column, float[] v)`
Sets the specified column of this matrix4f to the four values provided.
`void`
`setElement(int row, int col, float v)`
Sets the specified element of this matrix4f to the value provided.
`void`
`setIdentity()`
Sets this Matrix4f to identity.
`M4`
`setM4(M4 m1)`
Sets the value of this matrix to a copy of the passed matrix m1.
`void`
`setMV(M3 m1, T3 t)`
Initializes a Matrix4f from the rotation matrix and translation.
`void`
`setRotationScale(M3 m1)`
Replaces the upper 3x3 matrix values of this matrix with the values in the matrix m1.
`void`
`setRowA(int row, float[] v)`
Sets the specified row of this matrix4f to the four values provided.
`void`
`setToAA(A4 a)`
Sets the rotational component (upper 3x3) of this matrix to a rotation given by an axis angle
`void`
`setToM3(M34 m1)`
Sets the rotational component (upper 3x3) of this matrix to the matrix values in the single precision Matrix3f argument; the other elements of this matrix are initialized as if this were an identity matrix (ie, affine matrix with no translational component).
`void`
`setTranslation(T3 trans)`
Modifies the translational components of this matrix to the values of the Vector3f argument; the other values of this matrix are not modified.
`void`
`setZero()`
Sets this matrix to all zeros.
`void`
`sub(M4 m1)`
Sets the value of this matrix to the matrix difference of itself and matrix m1 (this = this - m1).
`String`
`toString()`
Returns a string that contains the values of this Matrix4f.
`void`
`transform(T4 vec)`
Transform the vector vec using this Matrix4f and place the result back into vec.
`void`
`transform2(T4 vec, T4 vecOut)`
Transform the vector vec using this Matrix4f and place the result into vecOut.
`void`
`transpose()`
Sets the value of this matrix to its transpose.

### Methods inherited from class M34

`add33, clear33, determinant3, err, get33, getColumn33, getRow33, mul33, rotate, rotate2, set33, setAA33, setColumn33, setM33, setRow33, setXRot, setYRot, setZRot, sub33, transpose33`

### Methods inherited from class Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Field Details

### m03

public float m03
The fourth element of the first row.

### m13

public float m13
The fourth element of the second row.

### m23

public float m23
The fourth element of the third row.

### m30

public float m30
The first element of the fourth row.

### m31

public float m31
The second element of the fourth row.

### m32

public float m32
The third element of the fourth row.

### m33

public float m33
The fourth element of the fourth row.

## Constructor Details

### M4

public M4()
all zeros

## Method Details

### newA16

public static M4 newA16(float[] v)
Constructs and initializes a Matrix4f from the specified 16 element array. this.m00 =v[0], this.m01=v[1], etc.

Parameters:
  `v` - the array of length 16 containing in order
Returns:
  m

### newM4

public static M4 newM4(M4 m1)
Constructs a new matrix with the same values as the Matrix4f parameter.

Parameters:
  `m1` - the source matrix
Returns:
  m

### newMV

public static M4 newMV(M3 m1, T3 t)
Constructs and initializes a Matrix4f from the rotation matrix and translation.

Parameters:
  `m1` - The rotation matrix representing the rotational components
  `t` - The translational components of the matrix
Returns:
  m

### setZero

public void setZero()
Sets this matrix to all zeros.

### setIdentity

public void setIdentity()
Sets this Matrix4f to identity.

### setM4

public M4 setM4(M4 m1)
Sets the value of this matrix to a copy of the passed matrix m1.

Parameters:
  `m1` - the matrix to be copied
Returns:
  this

### setMV

public void setMV(M3 m1, T3 t)
Initializes a Matrix4f from the rotation matrix and translation.

Parameters:
  `m1` - The rotation matrix representing the rotational components
  `t` - The translational components of the matrix

### setToM3

public void setToM3(M34 m1)
Sets the rotational component (upper 3x3) of this matrix to the matrix values in the single precision Matrix3f argument; the other elements of this matrix are initialized as if this were an identity matrix (ie, affine matrix with no translational component).

Parameters:
  `m1` - the 3x3 matrix

### setToAA

public void setToAA(A4 a)
Sets the rotational component (upper 3x3) of this matrix to a rotation given by an axis angle

Parameters:
  `a` - the axis and angle to be converted

### setA

public void setA(float[] m)
Sets the values in this Matrix4f equal to the row-major array parameter (ie, the first four elements of the array will be copied into the first row of this matrix, etc.).

Parameters:
  `m` -

### setTranslation

public void setTranslation(T3 trans)
Modifies the translational components of this matrix to the values of the Vector3f argument; the other values of this matrix are not modified.

Parameters:
  `trans` - the translational component

### setElement

public void setElement(int row, int col, float v)
Sets the specified element of this matrix4f to the value provided.

Parameters:
  `row` - the row number to be modified (zero indexed)
  `col` - the column number to be modified (zero indexed)
  `v` - the new value

### getElement

public float getElement(int row, int col)
Retrieves the value at the specified row and column of this matrix.

Parameters:
  `row` - the row number to be retrieved (zero indexed)
  `col` - the column number to be retrieved (zero indexed)
Returns:
  the value at the indexed element

### getTranslation

public void getTranslation(T3 trans)
Retrieves the translational components of this matrix.

Parameters:
  `trans` - the vector that will receive the translational component

### getRotationScale

public void getRotationScale(M3 m1)
Gets the upper 3x3 values of this matrix and places them into the matrix m1.

Parameters:
  `m1` - The matrix that will hold the values

### setRotationScale

public void setRotationScale(M3 m1)
Replaces the upper 3x3 matrix values of this matrix with the values in the matrix m1.

Parameters:
  `m1` - The matrix that will be the new upper 3x3

### setRowA

public void setRowA(int row, float[] v)
Sets the specified row of this matrix4f to the four values provided.

Parameters:
  `row` - the row number to be modified (zero indexed)
  `v` - the replacement row

### getRow

public void getRow(int row, float[] v)
Copies the matrix values in the specified row into the array parameter.

Specified by:
  `getRow` in class `M34`
Parameters:
  `row` - the matrix row
  `v` - The array into which the matrix row values will be copied

### setColumn4

public void setColumn4(int column, float x, float y, float z, float w)
Sets the specified column of this matrix4f to the four values provided.

Parameters:
  `column` - the column number to be modified (zero indexed)
  `x` - the first row element
  `y` - the second row element
  `z` - the third row element
  `w` - the fourth row element

### setColumnA

public void setColumnA(int column, float[] v)
Sets the specified column of this matrix4f to the four values provided.

Parameters:
  `column` - the column number to be modified (zero indexed)
  `v` - the replacement column

### getColumn

public void getColumn(int column, float[] v)
Copies the matrix values in the specified column into the array parameter.

Parameters:
  `column` - the matrix column
  `v` - The array into which the matrix column values will be copied

### sub

public void sub(M4 m1)
Sets the value of this matrix to the matrix difference of itself and matrix m1 (this = this - m1).

Parameters:
  `m1` - the other matrix

### add

public void add(T3 pt)
add to translation

Parameters:
  `pt` -

### transpose

public void transpose()
Sets the value of this matrix to its transpose.

### invert

public M4 invert()
Sets the value of this matrix to its inverse.

Returns:
  this

### determinant4

public float determinant4()
Computes the determinant of this matrix.

Returns:
  the determinant of the matrix

### scale

public void scale(float scalar)
Multiplies each element of this matrix by a scalar.

Parameters:
  `scalar` - The scalar multiplier.

### mul

public void mul(M4 m1)
Sets the value of this matrix to the result of multiplying itself with matrix m1.

Parameters:
  `m1` - the other matrix

### mul2

public void mul2(M4 m1, M4 m2)
Sets the value of this matrix to the result of multiplying the two argument matrices together.

Parameters:
  `m1` - the first matrix
  `m2` - the second matrix

### transform

public void transform(T4 vec)
Transform the vector vec using this Matrix4f and place the result back into vec.

Parameters:
  `vec` - the single precision vector to be transformed

### transform2

public void transform2(T4 vec, T4 vecOut)
Transform the vector vec using this Matrix4f and place the result into vecOut.

Parameters:
  `vec` - the single precision vector to be transformed
  `vecOut` - the vector into which the transformed values are placed

### rotTrans

public void rotTrans(T3 point)
Transforms the point parameter with this Matrix4f and places the result back into point. The fourth element of the point input parameter is assumed to be one.

Parameters:
  `point` - the input point to be transformed.

### rotTrans2

public T3 rotTrans2(T3 point, T3 pointOut)
Transforms the point parameter with this Matrix4f and places the result into pointOut. The fourth element of the point input parameter is assumed to be one. point may be pointOut

Parameters:
  `point` - the input point to be transformed.
  `pointOut` - the transformed point
Returns:
  pointOut

### setAsXYRotation

public M4 setAsXYRotation(float angle)
Sets the value of this matrix to a rotation matrix about the w axis by the passed angle.

Parameters:
  `angle` - the angle to rotate about the W axis in radians
Returns:
  this

### setAsYZRotation

public M4 setAsYZRotation(float angle)
Sets the value of this matrix to a rotation matrix about the w axis by the passed angle.

Parameters:
  `angle` - the angle to rotate about the W axis in radians
Returns:
  this

### setAsXZRotation

public M4 setAsXZRotation(float angle)
Sets the value of this matrix to a rotation matrix about the w axis by the passed angle.

Parameters:
  `angle` - the angle to rotate about the W axis in radians
Returns:
  this

### equals

public boolean equals(Object o)
Returns true if the Object o is of type Matrix4f and all of the data members of t1 are equal to the corresponding data members in this Matrix4f.

Overrides:
  `equals` in class `Object`
Parameters:
  `o` - the object with which the comparison is made.

### hashCode

public int hashCode()
Returns a hash number based on the data values in this object. Two different Matrix4f objects with identical data values (ie, returns true for equals(Matrix4f) ) will return the same hash number. Two objects with different data members may return the same hash value, although this is not likely.

Overrides:
  `hashCode` in class `Object`
Returns:
  the integer hash value

### toString

public String toString()
Returns a string that contains the values of this Matrix4f.

Overrides:
  `toString` in class `Object`
Returns:
  the String representation

### round

public M4 round(float f)