- public T newT(Vert p1, Vert p2, Vert p3, Vec norm) {
- if (norm != null) {
- Vec norm2 = p3.p.minus(p1.p).cross(p2.p.minus(p1.p));
- float dot = norm.dot(norm2);
- //if (Math.abs(dot) < EPointSILON) throw new Error("dot products within epsilon of each other: "+norm+" "+norm2);
- if (dot < 0) { Vert p = p1; p1=p2; p2 = p; }
- }
- E e12 = p1.makeE(p2);
- E e23 = p2.makeE(p3);
- E e31 = p3.makeE(p1);
- while(e12.next != e23 || e23.next != e31 || e31.next != e12) {
- e12.makeAdjacent(e23);
- e23.makeAdjacent(e31);
- e31.makeAdjacent(e12);
- }
- T ret = e12.makeT();
- if (e12.t == null) throw new Error();
- if (e23.t == null) throw new Error();
- if (e31.t == null) throw new Error();
- return ret;
- }
-