+ public float circumcircleRadius() {
+ double a = p1().distance(p2());
+ double b = p2().distance(p3());
+ double c = p3().distance(p1());
+ return (float)((a*b*c)/Math.sqrt((a+b+c)*(b+c-a)*(c+a-b)*(a+b-c)));
+ }
+
+ public float shortestEdgeLength() {
+ float a = p1().distance(p2());
+ float b = p2().distance(p3());
+ float c = p3().distance(p1());
+ return Math.min(a, Math.min(b,c));
+ }
+
+ /** a number ranging from 0..1 with 0 being lower quality */
+ public float quality() {
+ float d = shortestEdgeLength();
+ float r = circumcircleRadius();
+ if (r==0) throw new Error();
+ float ret = (float)((d*Math.cos(Math.PI/6))/(r*2));
+ if (ret < 0 || ret > 1) throw new Error("ret="+ret);
+ return ret;
+ }
+
+ // FIXME: I stole this off the net, and I need to credit whoever wrote it