From 35b9db0def4913851f7515f2525cffb01a940578 Mon Sep 17 00:00:00 2001 From: adam Date: Tue, 4 Dec 2007 22:29:54 -0800 Subject: [PATCH] checkpoint darcs-hash:20071205062954-5007d-0b652b5a26bee0079d1e50429a5ee9c447707e44.gz --- src/edu/berkeley/qfat/Mesh.java | 11 +++++++++++ src/edu/berkeley/qfat/geom/Matrix.java | 22 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/edu/berkeley/qfat/Mesh.java b/src/edu/berkeley/qfat/Mesh.java index 94b4e73..08d89e7 100644 --- a/src/edu/berkeley/qfat/Mesh.java +++ b/src/edu/berkeley/qfat/Mesh.java @@ -135,6 +135,17 @@ public class Mesh implements Iterable { float oldscore = 0; boolean inserted = false; + public Matrix quadric() { + Matrix m = new Matrix(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + E e = this.e; + do { + T t = e.t; + m = m.plus(t.norm().fundamentalQuadric(t.centroid())); + e = e.pair.next; + } while(e != this.e); + return m; + } + public Point getPoint() { return p; } private Vert(Point p) { this.p = p; diff --git a/src/edu/berkeley/qfat/geom/Matrix.java b/src/edu/berkeley/qfat/geom/Matrix.java index f617376..1f25ddc 100644 --- a/src/edu/berkeley/qfat/geom/Matrix.java +++ b/src/edu/berkeley/qfat/geom/Matrix.java @@ -6,7 +6,7 @@ public class Matrix { // [ a b c d ] [ x ] // [ e f g h ] [ y ] // [ i j k l ] [ z ] - // [ 0 0 0 1 ] [ 1 ] + // [ m n o p ] [ 1 ] // public final float a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p; public Matrix() { this(1); } @@ -36,9 +36,23 @@ public class Matrix { this.a = a; this.b = b; this.c = c; this.d = d; this.e = e; this.f = f; this.g = g; this.h = h; this.i = i; this.j = j; this.k = k; this.l = l; this.m = m; this.n = n; this.o = o; this.p = p; } + 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); + } public Matrix times(float x) { return new Matrix(a*x, b*x, c*x, d*x, e*x, f*x, g*x, h*x, i*x, j*x, k*x, l*x, m*x, n*x, o*x, p*x); } + + /** computes (v^T)(this)(v) */ + public float preAndPostMultiply(Point point) { + float ret = + ((a*point.x + b*point.y + c*point.z + d) * point.x) + + ((e*point.x + f*point.y + g*point.z + h) * point.y) + + ((i*point.x + j*point.y + k*point.z + l) * point.z) + + ((m*point.x + n*point.y + o*point.z + p) * 1); + return ret; + } + public Matrix(Vec axis, float angle) { double q = Math.cos(angle); double s = Math.sin(angle); @@ -68,6 +82,12 @@ public class Matrix { e*p.x + f*p.y + g*p.z + h, i*p.x + j*p.y + k*p.z + l); } + public Vec times(Vec p) { + // discards bottom row + return new Vec(a*p.x + b*p.y + c*p.z + d, + e*p.x + f*p.y + g*p.z + h, + i*p.x + j*p.y + k*p.z + l); + } public Point apply(Point p) { return p; } public Vec apply(Vec v) { return v; } public Matrix invert() { return this; } -- 1.7.10.4