0, 0, 0, 1);
}
+ public static Matrix reflect(Vec v) {
+ Vec reflectionPlaneNormal = v.norm();
+ float a = reflectionPlaneNormal.x;
+ float b = reflectionPlaneNormal.y;
+ float c = reflectionPlaneNormal.z;
+ return
+ new Matrix( 1-2*a*a, -2*a*b, -2*a*c, 0,
+ -2*a*b, 1-2*b*b, -2*b*c, 0,
+ -2*a*c, -2*b*c, 1-2*c*c, 0,
+ 0, 0, 0, 1);
+ }
+
+ public Vec getTranslationalComponent() {
+ return new Vec(d, h, l);
+ }
+
public Matrix plus(Matrix x) {
return new Matrix(a+x.a, b+x.b, c+x.c, d+x.d, e+x.e, f+x.f, g+x.g, h+x.h, i+x.i, j+x.j, k+x.k, l+x.l, m+x.m, n+x.n, o+x.o, p+x.p);
}
i*p.x + j*p.y + k*p.z + l);
}
+ public Matrix preMultiplyTranslationalComponentBy(Matrix mm) {
+ Vec v = mm.times(getTranslationalComponent());
+ return new Matrix(a, b, c, v.x,
+ e, f, g, v.y,
+ i, j, k, v.z,
+ m, n, o, 1);
+ }
+
/** multiply by another matrix */
public Matrix times(Matrix z) {
float t00 = a;
near(p,z.p);
}
private static final float EPSILON = 0.001f;
- private static boolean near(float a, float b) { return a==b; }
+ private static boolean near(float a, float b) { return Math.abs(a-b)<EPSILON; }
public int hashCode() {
return