1 package edu.berkeley.qfat.geom;
2 import javax.media.opengl.*;
4 public abstract class Triangle {
5 public abstract Point p1();
6 public abstract Point p2();
7 public abstract Point p3();
10 return p2().minus(p1()).cross(p3().minus(p1())).norm();
14 (float)Math.abs(0.5*p1().distance(p2())
15 * new Vec(p1(), p2()).norm().dot(new Vec(p2(), p3())));
17 public void glVertices(GL gl) {
22 public Point centroid() {
23 return new Point((p1().x+p2().x+p3().x)/3,
24 (p1().y+p2().y+p3().y)/3,
25 (p1().z+p2().z+p3().z)/3);
27 public float diameter() {
28 // FIXME: what is this supposed to be?
29 return Math.max(Math.max(p1().distance(p2()),
31 p3().distance(p1())) / 2;
34 public float aspect() {
35 float max = Math.max(Math.max(p1().distance(p2()),
37 p3().distance(p1())) / 2;
38 return 1/(1+area()/(max*max));
40 public float aspect0() {
41 float max = Math.max(Math.max(p1().distance(p2()),
43 p3().distance(p1())) / 2;
44 return (area()/(max*max));