}
+ public static void getMatrix(Quat4d quat, Matrix4d m) {
+ m.setZero();
+ m.m00 = 1.0f - 2.0 * (quat.y * quat.y + quat.z * quat.z);
+ m.m01 = 2.0 * (quat.x * quat.y + quat.w * quat.z);
+ m.m02 = 2.0 * (quat.x * quat.z - quat.w * quat.y);
+ m.m10 = 2.0 * (quat.x * quat.y - quat.w * quat.z);
+ m.m11 = 1.0 - 2.0f * (quat.x * quat.x + quat.z * quat.z);
+ m.m12 = 2.0 * (quat.y * quat.z + quat.w * quat.x);
+ m.m20 = 2.0 * (quat.x * quat.z + quat.w * quat.y);
+ m.m21 = 2.0 * (quat.y * quat.z - quat.w * quat.x);
+ m.m22 = 1.0 - 2.0f * (quat.x * quat.x + quat.y * quat.y);
+ m.m33 = 1.0;
+ }
private static double q[] = new double[3];
private static int nxt[] = { 1, 2, 0 };
}
return t;
}
+
+ public static Matrix4d glFrustum(double l, double r, double b, double t, double n, double f) {
+ Matrix4d mat = new Matrix4d();
+ mat.m00 = 2.0 * n / (r - l);
+ mat.m11 = 2.0 * n / (t - b);
+ mat.m02 = (r+l) / (r-l);
+ mat.m12 = (t+b) / (t-b);
+ mat.m22 = -(f+n) / (f-n);
+ mat.m23 = -(2.0 *f * n) / (f-n);
+ mat.m32 = -1.0;
+ return mat;
+ }
+
+ public static Matrix4d glOrtho(double l, double r, double b, double t, double n, double f) {
+ Matrix4d mat = new Matrix4d();
+ mat.m00 = 2.0 / (r - l);
+ mat.m11 = 2.0 / (t - b);
+ mat.m22 = -2.0 / (f-n);
+ mat.m33 = 1.0;
+ mat.m03 = -(r+l)/(r-l);
+ mat.m13 = -(t+b)/(t-b);
+ mat.m23 = -(f+n)/(f-n);
+ return mat;
+ }
}