X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2Fgeom%2FMatrix.java;h=31fe6e0ef849ab0037a99f3c084085542de6a590;hb=42acb5af8ff15b7af9fa8f34c071ee58e24faf98;hp=dbe4076b9f4d214f66b81e80c48a207205f638f3;hpb=e6ede2b794c97801f3890af9ea634e67012420ef;p=anneal.git diff --git a/src/edu/berkeley/qfat/geom/Matrix.java b/src/edu/berkeley/qfat/geom/Matrix.java index dbe4076..31fe6e0 100644 --- a/src/edu/berkeley/qfat/geom/Matrix.java +++ b/src/edu/berkeley/qfat/geom/Matrix.java @@ -71,6 +71,22 @@ public class Matrix { 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); } @@ -106,6 +122,14 @@ public class Matrix { 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;