X-Git-Url: http://git.megacz.com/?p=anneal.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2Fgeom%2FPlane.java;h=b3aacdd492ffecdd71f8062e0a681df2e608683d;hp=1789e55aee635d8773cdff9b74963f8cfce8a9d3;hb=64c6939d78acfa06e7bc380cb713e3800bf16be5;hpb=de2400d58116bd995e73baf7a429e22def1e4067 diff --git a/src/edu/berkeley/qfat/geom/Plane.java b/src/edu/berkeley/qfat/geom/Plane.java index 1789e55..b3aacdd 100644 --- a/src/edu/berkeley/qfat/geom/Plane.java +++ b/src/edu/berkeley/qfat/geom/Plane.java @@ -1,27 +1,48 @@ package edu.berkeley.qfat.geom; import javax.media.opengl.*; -public class Plane { +public class Plane implements AffineConstraint { - // FIXME: could be given by // ax+by+cz=d + public final float a, b, c, d; - public final Vec norm; - public final float dvalue; + public Vec norm() { return new Vec(a, b, c); } public Plane(Point p, Vec norm) { - this.norm = norm.norm(); - this.dvalue = p.x*this.norm.x+p.y*this.norm.y+p.z*this.norm.z; + this.a = norm.x; + this.b = norm.y; + this.c = norm.z; + this.d = p.x*norm.x+p.y*norm.y+p.z*norm.z; + } + + /** provided at least one of a,b,c is nonzero, return the Plane representing ax+by+cz=d */ + public Plane(float a, float b, float c, float d) { + this.a = a; + this.b = b; + this.c = c; + this.d = d; } public Point intersect(Plane p1, Plane p2) { + Vec norm = norm(); Plane p3 = this; - float z = p1.norm.dot(p2.norm.cross(p3.norm)); + float z = p1.norm().dot(p2.norm().cross(p3.norm())); if (Math.abs(z) < 0.0001) return null; // planes do not intersect at a point - Vec v1 = p2.norm.cross(p3.norm).times(-1 * p1.dvalue); - Vec v2 = p3.norm.cross(p1.norm).times(-1 * p2.dvalue); - Vec v3 = p1.norm.cross(p2.norm).times(-1 * p3.dvalue); + Vec v1 = p2.norm().cross(p3.norm()).times(-1 * p1.d); + Vec v2 = p3.norm().cross(p1.norm()).times(-1 * p2.d); + Vec v3 = p1.norm().cross(p2.norm()).times(-1 * p3.d); return Point.ZERO.plus(v1.plus(v2).plus(v3).times(1/z)); } + public Point getProjection(Point p) { + throw new RuntimeException("not implemented yet"); + } + + public AffineConstraint intersect(AffineConstraint c, float epsilon) { + throw new RuntimeException("not implemented yet"); + } + + public AffineConstraint multiply(Matrix m) { + throw new RuntimeException("not yet implemented"); + } }