/** * Sets this matrix to an identity matrix. * @return this identity matrix. */ public Matrix44 setIdentity() { set(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0); return this; }
/** * Constructs a copy of the specified matrix. * @param m the matrix. */ public Matrix44(Matrix44 m) { set(m.m[ 0],m.m[ 4],m.m[ 8],m.m[12], m.m[ 1],m.m[ 5],m.m[ 9],m.m[13], m.m[ 2],m.m[ 6],m.m[10],m.m[14], m.m[ 3],m.m[ 7],m.m[11],m.m[15]); }
/** * Sets this matrix to a translation-only matrix. * @param tx the x component of the translation. * @param ty the y component of the translation. * @param tz the z component of the translation. * @return this translation-only matrix. */ public Matrix44 setTranslate(double tx, double ty, double tz) { set(1.0, 0.0, 0.0, tx, 0.0, 1.0, 0.0, ty, 0.0, 0.0, 1.0, tz, 0.0, 0.0, 0.0, 1.0); return this; }
/** * Sets this matrix to a scaling-only matrix. * @param sx the x component of the scaling. * @param sy the y component of the scaling. * @param sz the z component of the scaling. * @return this scaling-only matrix. */ public Matrix44 setScale(double sx, double sy, double sz) { set( sx, 0.0, 0.0, 0.0, 0.0, sy, 0.0, 0.0, 0.0, 0.0, sz, 0.0, 0.0, 0.0, 0.0, 1.0); return this; }
/** * Constructs a matrix with specified elements. * @param m00 the element with (row,col) indices (0,0) * @param m01 the element with (row,col) indices (0,1) * @param m02 the element with (row,col) indices (0,2) * @param m03 the element with (row,col) indices (0,3) * @param m10 the element with (row,col) indices (1,0) * @param m11 the element with (row,col) indices (1,1) * @param m12 the element with (row,col) indices (1,2) * @param m13 the element with (row,col) indices (1,3) * @param m20 the element with (row,col) indices (2,0) * @param m21 the element with (row,col) indices (2,1) * @param m22 the element with (row,col) indices (2,2) * @param m23 the element with (row,col) indices (2,3) * @param m30 the element with (row,col) indices (3,0) * @param m31 the element with (row,col) indices (3,1) * @param m32 the element with (row,col) indices (3,2) * @param m33 the element with (row,col) indices (3,3) */ public Matrix44(double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23, double m30, double m31, double m32, double m33) { set(m00,m01,m02,m03, m10,m11,m12,m13, m20,m21,m22,m23, m30,m31,m32,m33); }
/** * Sets this matrix to a rotation-only matrix. * The rotation is about the x axis. * @param ra the angle of rotation, in degrees. * @return this rotation-only matrix. */ public Matrix44 setRotateX(double ra) { double ca = Math.cos(ra*D2R); double sa = Math.sin(ra*D2R); set(1.0, 0.0, 0.0, 0.0, 0.0, ca, -sa, 0.0, 0.0, sa, ca, 0.0, 0.0, 0.0, 0.0, 1.0); return this; }
/** * Sets this matrix to a rotation-only matrix. * The rotation is about the y axis. * @param ra the angle of rotation, in degrees. * @return this rotation-only matrix. */ public Matrix44 setRotateY(double ra) { double ca = Math.cos(ra*D2R); double sa = Math.sin(ra*D2R); set( ca, 0.0, sa, 0.0, 0.0, 1.0, 0.0, 0.0, -sa, 0.0, ca, 0.0, 0.0, 0.0, 0.0, 1.0); return this; }
/** * Sets this matrix to a rotation-only matrix. * The rotation is about the z axis. * @param ra the angle of rotation, in degrees. * @return this rotation-only matrix. */ public Matrix44 setRotateZ(double ra) { double ca = Math.cos(ra*D2R); double sa = Math.sin(ra*D2R); set( ca, -sa, 0.0, 0.0, sa, ca, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0); return this; }
double m21 = zy + ca*(0.0-zy) + sa*( rx); double m22 = zz + ca*(1.0-zz) + sa*(0.0); set(m00, m01, m02, 0.0, m10, m11, m12, 0.0, m20, m21, m22, 0.0,
double sy = 2.0/(top-bottom); double sz = -2.0/(zfar-znear); set( sx, 0.0, 0.0, tx, 0.0, sy, 0.0, ty, 0.0, 0.0, sz, tz,
double c = (znear+zfar)/(znear-zfar); double d = 2.0*zfar*znear/(znear-zfar); set( sx, 0.0, a, 0.0, 0.0, sy, b, 0.0, 0.0, 0.0, c, d,