X-Git-Url: http://git.megacz.com/?p=anneal.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2Fgeom%2FMatrix.java;h=c2419d6fa7aa9f3179da3304522ed724a95548dd;hp=dda82855c23042ed920d088ee4dd9f6303798eab;hb=553823b9fbe373bbc8b5409c423857253f18c4aa;hpb=de2400d58116bd995e73baf7a429e22def1e4067 diff --git a/src/edu/berkeley/qfat/geom/Matrix.java b/src/edu/berkeley/qfat/geom/Matrix.java index dda8285..c2419d6 100644 --- a/src/edu/berkeley/qfat/geom/Matrix.java +++ b/src/edu/berkeley/qfat/geom/Matrix.java @@ -366,4 +366,23 @@ public class Matrix { return z.times(p).times(m); } + /** returns the constraint-conjunction "(forall v)Mv=v" */ + public AffineConstraint getAffineConstraint(float epsilon) { + AffineConstraint c1 = getAffineConstraint(a-1, b, c, d , epsilon); + AffineConstraint c2 = getAffineConstraint(e, f-1, g, h , epsilon); + AffineConstraint c3 = getAffineConstraint(i, j, k-1, l , epsilon); + // FIXME: bottom row constraint? + return c1.intersect(c2.intersect(c3, epsilon), epsilon); + } + + /** the AffineConstraint representing ax+by+cz+d=0 */ + private static AffineConstraint getAffineConstraint(float a, float b, float c, float d, float epsilon) { + a = Math.abs(a) <= epsilon ? 0 : a; + b = Math.abs(b) <= epsilon ? 0 : b; + c = Math.abs(c) <= epsilon ? 0 : c; + d = Math.abs(d) <= epsilon ? 0 : d; + if (a!=0 || b!=0 || c!=0) return new Plane(a, b, c, d); + if (d==0) return new AffineConstraint.All(); + return new AffineConstraint.Nothing(); + } }