1 package edu.berkeley.qfat.geom;
2 import javax.media.opengl.*;
4 public class Plane implements AffineConstraint {
7 public final float a, b, c, d;
9 public Vec norm() { return new Vec(a, b, c); }
11 public Plane(Point p, Vec norm) {
15 this.d = p.x*norm.x+p.y*norm.y+p.z*norm.z;
18 /** provided at least one of a,b,c is nonzero, return the Plane representing ax+by+cz=d */
19 public Plane(float a, float b, float c, float d) {
26 public Point intersect(Plane p1, Plane p2) {
29 float z = p1.norm().dot(p2.norm().cross(p3.norm()));
30 if (Math.abs(z) < 0.0001) return null; // planes do not intersect at a point
31 Vec v1 = p2.norm().cross(p3.norm()).times(-1 * p1.d);
32 Vec v2 = p3.norm().cross(p1.norm()).times(-1 * p2.d);
33 Vec v3 = p1.norm().cross(p2.norm()).times(-1 * p3.d);
34 return Point.ZERO.plus(v1.plus(v2).plus(v3).times(1/z));
37 public Point getProjection(Point p) {
38 throw new RuntimeException("not implemented yet");
41 public AffineConstraint intersect(AffineConstraint c, float epsilon) {
42 throw new RuntimeException("not implemented yet");
45 public AffineConstraint multiply(Matrix m) {
46 throw new RuntimeException("not yet implemented");