4 * A base class for both M3 and M4 to conserve code size.
6 * @author Kenji hiranabe
8 * additions by Bob Hanson hansonr@stolaf.edu 9/30/2012 for unique
9 * constructor and method names for the optimization of compiled
10 * JavaScript using Java2Script and for subclassing to M3 and M4
13 public abstract class M34 {
16 * The first element of the first row
21 * The second element of the first row.
26 * third element of the first row.
31 * The first element of the second row.
36 * The second element of the second row.
41 * The third element of the second row.
46 * The first element of the third row.
51 * The second element of the third row.
56 * The third element of the third row.
60 protected void setAA33(A4 a) {
64 double angle = a.angle;
65 // Taken from Rick's which is taken from Wertz. pg. 412
66 // Bug Fixed and changed into right-handed by hiranabe
67 double n = Math.sqrt(x * x + y * y + z * z);
73 double c = Math.cos(angle);
74 double s = Math.sin(angle);
76 m00 = (float) (c + x * x * omc);
77 m11 = (float) (c + y * y * omc);
78 m22 = (float) (c + z * z * omc);
80 double tmp1 = x * y * omc;
82 m01 = (float) (tmp1 - tmp2);
83 m10 = (float) (tmp1 + tmp2);
87 m02 = (float) (tmp1 + tmp2);
88 m20 = (float) (tmp1 - tmp2);
92 m12 = (float) (tmp1 - tmp2);
93 m21 = (float) (tmp1 + tmp2);
96 public void rotate(T3 t) {
102 * Transform the vector vec using this Matrix3f and place the result into
106 * the single precision vector to be transformed
108 * the vector into which the transformed values are placed
110 public void rotate2(T3 t, T3 result) {
112 result.set(m00 * t.x + m01 * t.y + m02 * t.z, m10 * t.x + m11 * t.y + m12
113 * t.z, m20 * t.x + m21 * t.y + m22 * t.z);
118 * Sets the value of this matrix to the double value of the Matrix3f argument.
123 protected void setM33(M34 m1) {
135 protected void clear33() {
136 m00 = m01 = m02 = m10 = m11 = m12 = m20 = m21 = m22 = 0.0f;
139 protected void set33(int row, int col, float v) {
184 protected float get33(int row, int col) {
221 protected void setRow33(int row, float v[]) {
243 public abstract void getRow(int row, float v[]);
245 protected void getRow33(int row, float v[]) {
266 protected void setColumn33(int column, float v[]) {
288 protected void getColumn33(int column, float v[]) {
310 protected void add33(M34 m1) {
322 protected void sub33(M34 m1) {
334 protected void mul33(float x) {
346 protected void transpose33() {
360 protected void setXRot(float angle) {
361 double c = Math.cos(angle);
362 double s = Math.sin(angle);
374 protected void setYRot(float angle) {
375 double c = Math.cos(angle);
376 double s = Math.sin(angle);
388 protected void setZRot(float angle) {
389 double c = Math.cos(angle);
390 double s = Math.sin(angle);
403 * @return 3x3 determinant
405 public float determinant3() {
406 return m00 * (m11 * m22 - m21 * m12) - m01 * (m10 * m22 - m20 * m12) + m02
407 * (m10 * m21 - m20 * m11);
410 protected void err() {
411 throw new ArrayIndexOutOfBoundsException(
412 "matrix column/row out of bounds");