1 package edu.berkeley.qfat.geom;
2 import javax.media.opengl.*;
7 public final float dvalue;
9 public Plane(Point p, Vec norm) {
10 this.norm = norm.norm();
11 this.dvalue = p.x*this.norm.x+p.y*this.norm.y+p.z*this.norm.z;
14 public Point intersect(Plane p1, Plane p2) {
16 float z = p1.norm.dot(p2.norm.cross(p3.norm));
17 if (Math.abs(z) < 0.0001) return null; // planes do not intersect at a point
18 Vec v1 = p2.norm.cross(p3.norm).times(-1 * p1.dvalue);
19 Vec v2 = p3.norm.cross(p1.norm).times(-1 * p2.dvalue);
20 Vec v3 = p1.norm.cross(p2.norm).times(-1 * p3.dvalue);
21 return Point.ORIGIN.plus(v1.plus(v2).plus(v3).times(1/z));