public E e1() { return e1; }
public E e2() { return e1.next; }
public E e3() { return e1.prev; }
- public Vec norm() { return v2().p.minus(v1().p).cross(v3().p.minus(v1().p)).norm(); }
public boolean hasE(E e) { return e1==e || e1.next==e || e1.prev==e; }
public boolean has(Vert v) { return v1()==v || v2()==v || v3()==v; }
- public float area() { return (float)Math.abs(0.5*e1().length()*new Vec(v1().p, v2().p).norm().dot(new Vec(v2().p, v3().p))); }
- public void glVertices(GL gl) {
- v1().p.glVertex(gl);
- v2().p.glVertex(gl);
- v3().p.glVertex(gl);
- }
- public Point centroid() {
- return new Point((v1().p.x+v2().p.x+v3().p.x)/3,
- (v1().p.y+v2().p.y+v3().p.y)/3,
- (v1().p.z+v2().p.z+v3().p.z)/3); }
- public float diameter() {
- // FIXME: what is this supposed to be?
- return Math.max(Math.max(e1().length(), e2().length()), e3().length()) / 2;
- }
}
public abstract Point p1();
public abstract Point p2();
public abstract Point p3();
+
+ public Vec norm() {
+ return p2().minus(p1()).cross(p3().minus(p1())).norm();
+ }
+ public float area() {
+ return
+ (float)Math.abs(0.5*p1().distance(p2())
+ * new Vec(p1(), p2()).norm().dot(new Vec(p2(), p3())));
+ }
+ public void glVertices(GL gl) {
+ p1().glVertex(gl);
+ p2().glVertex(gl);
+ p3().glVertex(gl);
+ }
+ public Point centroid() {
+ return new Point((p1().x+p2().x+p3().x)/3,
+ (p1().y+p2().y+p3().y)/3,
+ (p1().z+p2().z+p3().z)/3);
+ }
+ public float diameter() {
+ // FIXME: what is this supposed to be?
+ return Math.max(Math.max(p1().distance(p2()),
+ p2().distance(p3())),
+ p3().distance(p1())) / 2;
+ }
}
\ No newline at end of file