- m.times(t.e1().p1.goodp).glVertex(gl);
- m.times(t.e1().p2.goodp).glVertex(gl);
- m.times(t.e2().p1.goodp).glVertex(gl);
- m.times(t.e2().p2.goodp).glVertex(gl);
- m.times(t.e3().p1.goodp).glVertex(gl);
- m.times(t.e3().p2.goodp).glVertex(gl);
+ // fixme used to be .goodp
+ m.times(t.e1().v1.p).glVertex(gl);
+ m.times(t.e1().v2.p).glVertex(gl);
+ m.times(t.e2().v1.p).glVertex(gl);
+ m.times(t.e2().v2.p).glVertex(gl);
+ m.times(t.e3().v1.p).glVertex(gl);
+ m.times(t.e3().v2.p).glVertex(gl);
if (nearest_in_other_mesh != null)
nearest_in_other_mesh.reComputeError();
for(E e = this.e; e!=null; e=e.pair.next==this.e?null:e.pair.next)
if (nearest_in_other_mesh != null)
nearest_in_other_mesh.reComputeError();
for(E e = this.e; e!=null; e=e.pair.next==this.e?null:e.pair.next)
T t = (T)o;
if (illegal) return false;
for(E e = Vertex.this.e; e!=null; e=e.pair.next==Vertex.this.e?null:e.pair.next) {
T t = (T)o;
if (illegal) return false;
for(E e = Vertex.this.e; e!=null; e=e.pair.next==Vertex.this.e?null:e.pair.next) {
- if (!e.t.has(t.e1().p1) && !e.t.has(t.e1().p2) && t.e1().intersects(e.t)) { illegal = true; }
- if (!e.t.has(t.e2().p1) && !e.t.has(t.e2().p2) && t.e2().intersects(e.t)) { illegal = true; }
- if (!e.t.has(t.e3().p1) && !e.t.has(t.e3().p2) && t.e3().intersects(e.t)) { illegal = true; }
+ if (!e.t.has(t.e1().v1) && !e.t.has(t.e1().v2) && t.e1().intersects(e.t)) { illegal = true; }
+ if (!e.t.has(t.e2().v1) && !e.t.has(t.e2().v2) && t.e2().intersects(e.t)) { illegal = true; }
+ if (!e.t.has(t.e3().v1) && !e.t.has(t.e3().v2) && t.e3().intersects(e.t)) { illegal = true; }
public E getFreeIncident(E start, E before) {
for(E e = start; e!=null; e=e.pair.next==before?null:e.pair.next)
public E getFreeIncident(E start, E before) {
for(E e = start; e!=null; e=e.pair.next==before?null:e.pair.next)
- public E getE(Vertex p2) {
- if (this.e!=null && this!=this.e.p1 && this!=this.e.p2) throw new RuntimeException();
+ public E getE(Vertex v2) {
+ if (this.e!=null && this!=this.e.v1 && this!=this.e.v2) throw new RuntimeException();
- if (pair!=null && (pair.p1!=p2 || pair.p2!=p1)) throw new RuntimeException();
- if (next!=null && next.p1!=p2) throw new RuntimeException();
- if (prev!=null && prev.p2!=p1) throw new RuntimeException();
+ if (pair!=null && (pair.v1!=v2 || pair.v2!=v1)) throw new RuntimeException();
+ if (next!=null && next.v1!=v2) throw new RuntimeException();
+ if (prev!=null && prev.v2!=v1) throw new RuntimeException();
T t; // triangle to our "left"
E prev; // previous half-edge
E next; // next half-edge
E pair; // partner half-edge
boolean shattered = false;
T t; // triangle to our "left"
E prev; // previous half-edge
E next; // next half-edge
E pair; // partner half-edge
boolean shattered = false;
- T t1 = newT(v1, v2, p2);
- T t2 = newT(v2, v1, p1);
+ T t1 = newT(v1, v2, this.v2);
+ T t2 = newT(v2, v1, this.v1);
- newT(v1e, v2e, e.p2).red = true;
- newT(v2e, v1e, e.p1).red = true;
+ newT(v1e, v2e, e.v2).red = true;
+ newT(v2e, v1e, e.v1).red = true;
v2e.getE(v1e).bindTo(e.getBindingMatrix(this), v1.getE(v2));
v1e.getE(v2e).bindTo(e.pair.getBindingMatrix(this.pair), v2.getE(v1));
}
v2e.getE(v1e).bindTo(e.getBindingMatrix(this), v1.getE(v2));
v1e.getE(v2e).bindTo(e.pair.getBindingMatrix(this.pair), v2.getE(v1));
}
Vertex nearest = error_against.nearest(midpoint());
float nearest_distance = midpoint().distance(nearest.p);
float other_distance =
Vertex nearest = error_against.nearest(midpoint());
float nearest_distance = midpoint().distance(nearest.p);
float other_distance =
float a = reflectionPlaneNormal.x;
float b = reflectionPlaneNormal.y;
float c = reflectionPlaneNormal.z;
float a = reflectionPlaneNormal.x;
float b = reflectionPlaneNormal.y;
float c = reflectionPlaneNormal.z;
.times(reflectionMatrix)
.times(Matrix.translate(Point.ORIGIN.minus(e.midpoint()))));
System.out.println(reflectionPlaneNormal);
.times(reflectionMatrix)
.times(Matrix.translate(Point.ORIGIN.minus(e.midpoint()))));
System.out.println(reflectionPlaneNormal);
- System.out.println(" " + p1.p + " " + m.times(e.p1.p));
- System.out.println(" " + p2.p + " " + m.times(e.p2.p));
+ System.out.println(" " + v1.p + " " + m.times(e.v1.p));
+ System.out.println(" " + v2.p + " " + m.times(e.v2.p));
- if (m.times(e.p1.p).minus(p1.p).mag() > EPSILON) throw new Error();
- if (m.times(e.p2.p).minus(p2.p).mag() > EPSILON) throw new Error();
+ if (m.times(e.v1.p).minus(v1.p).mag() > EPSILON) throw new Error();
+ if (m.times(e.v2.p).minus(v2.p).mag() > EPSILON) throw new Error();
- p1.bindTo(getBindingMatrix(e), e.p1);
- p2.bindTo(getBindingMatrix(e), e.p2);
- e.p1.setConstraint(getConstraint());
- e.p2.setConstraint(getConstraint());
+ v1.bindTo(getBindingMatrix(e), e.v1);
+ v2.bindTo(getBindingMatrix(e), e.v2);
+ e.v1.setConstraint(getConstraint());
+ e.v2.setConstraint(getConstraint());
- newT(r.p, e.p1.p, mid, null, 0);
- newT(r.p, mid, e.p2.p, null, 0);
- newT(l.p, mid, e.p1.p, null, 0);
- newT(l.p, e.p2.p, mid, null, 0);
+ newT(r.p, e.v1.p, mid, null, 0);
+ newT(r.p, mid, e.v2.p, null, 0);
+ newT(l.p, mid, e.v1.p, null, 0);
+ newT(l.p, e.v2.p, mid, null, 0);
- e.p1.getE(mid). bindTo(e.getBindingMatrix(firste), first);
- e.p1.getE(mid).pair. bindTo(e.getBindingMatrix(firste), first.pair);
- e.p2.getE(mid).pair. bindTo(e.getBindingMatrix(firste), firstq);
- e.p2.getE(mid).pair.pair.bindTo(e.getBindingMatrix(firste), firstq.pair);
+ e.v1.getE(mid). bindTo(e.getBindingMatrix(firste), first);
+ e.v1.getE(mid).pair. bindTo(e.getBindingMatrix(firste), first.pair);
+ e.v2.getE(mid).pair. bindTo(e.getBindingMatrix(firste), firstq);
+ e.v2.getE(mid).pair.pair.bindTo(e.getBindingMatrix(firste), firstq.pair);
- if (p2.e == this) throw new RuntimeException();
- if (pair.p2.e == pair) throw new RuntimeException();
+ if (v2.e == this) throw new RuntimeException();
+ if (pair.v2.e == pair) throw new RuntimeException();
- if (this.next.p1 != p2) throw new Error();
- if (this.prev.p2 != p1) throw new Error();
- if (this.p1.e == null) this.p1.e = this;
+ if (this.next.v1 != v2) throw new Error();
+ if (this.prev.v2 != v1) throw new Error();
+ if (this.v1.e == null) this.v1.e = this;
- public E(Point p1, Point p2) {
- if (vertices.get(p1) != null) throw new Error();
- if (vertices.get(p2) != null) throw new Error();
- this.p1 = new Vertex(p1);
- this.p2 = new Vertex(p2);
+ public E(Point v1, Point v2) {
+ if (vertices.get(v1) != null) throw new Error();
+ if (vertices.get(v2) != null) throw new Error();
+ this.v1 = new Vertex(v1);
+ this.v2 = new Vertex(v2);
sync();
}
/** adds a new half-edge to the mesh with a given predecessor, successor, and pair */
public E(E prev, E pair, E next) {
sync();
}
/** adds a new half-edge to the mesh with a given predecessor, successor, and pair */
public E(E prev, E pair, E next) {
- public Point midpoint() { return new Point((p1.p.x+p2.p.x)/2, (p1.p.y+p2.p.y)/2, (p1.p.z+p2.p.z)/2); }
- public boolean has(Vertex v) { return v==p1 || v==p2; }
- public float length() { return p1.p.minus(p2.p).mag(); }
- public String toString() { return p1+"->"+p2; }
+ public Point midpoint() { return new Point((v1.p.x+v2.p.x)/2, (v1.p.y+v2.p.y)/2, (v1.p.z+v2.p.z)/2); }
+ public boolean has(Vertex v) { return v==v1 || v==v2; }
+ public float length() { return v1.p.minus(v2.p).mag(); }
+ public String toString() { return v1+"->"+v2; }
- public T newT(HasPoint p1, HasPoint p2, HasPoint p3) {
- return newT(p1.getPoint(), p2.getPoint(), p3.getPoint(), null, 0);
+ public T newT(HasPoint v1, HasPoint v2, HasPoint v3) {
+ return newT(v1.getPoint(), v2.getPoint(), v3.getPoint(), null, 0);
- public T newT(Point p1, Point p2, Point p3, Vec norm, int colorclass) {
+ public T newT(Point v1, Point v2, Point v3, Vec norm, int colorclass) {
- for(Vertex v : vertices) { if (p1.distance(v.p) < EPSILON) { p1 = v.p; break; } }
- for(Vertex v : vertices) { if (p2.distance(v.p) < EPSILON) { p2 = v.p; break; } }
- for(Vertex v : vertices) { if (p3.distance(v.p) < EPSILON) { p3 = v.p; break; } }
+ for(Vertex v : vertices) { if (v1.distance(v.p) < EPSILON) { v1 = v.p; break; } }
+ for(Vertex v : vertices) { if (v2.distance(v.p) < EPSILON) { v2 = v.p; break; } }
+ for(Vertex v : vertices) { if (v3.distance(v.p) < EPSILON) { v3 = v.p; break; } }
- p1 = new Point(round(p1.x), round(p1.y), round(p1.z));
- p2 = new Point(round(p2.x), round(p2.y), round(p2.z));
- p3 = new Point(round(p3.x), round(p3.y), round(p3.z));
+ v1 = new Point(round(v1.x), round(v1.y), round(v1.z));
+ v2 = new Point(round(v2.x), round(v2.y), round(v2.z));
+ v3 = new Point(round(v3.x), round(v3.y), round(v3.z));
float dot = norm.dot(norm2);
//if (Math.abs(dot) < EPointSILON) throw new Error("dot products within evertsilon of each other: "+norm+" "+norm2);
float dot = norm.dot(norm2);
//if (Math.abs(dot) < EPointSILON) throw new Error("dot products within evertsilon of each other: "+norm+" "+norm2);
- newT(r.p, e.p1.p, mid, null, 0);
- newT(r.p, mid, e.p2.p, null, 0);
- newT(l.p, mid, e.p1.p, null, 0);
- newT(l.p, e.p2.p, mid, null, 0);
+ newT(r.p, e.v1.p, mid, null, 0);
+ newT(r.p, mid, e.v2.p, null, 0);
+ newT(l.p, mid, e.v1.p, null, 0);
+ newT(l.p, e.v2.p, mid, null, 0);
- e.p1.getE(mid). bindTo(e.getBindingMatrix(firste), first);
- e.p1.getE(mid).pair. bindTo(e.getBindingMatrix(firste), first.pair);
- e.p2.getE(mid).pair. bindTo(e.getBindingMatrix(firste), firstq);
- e.p2.getE(mid).pair.pair.bindTo(e.getBindingMatrix(firste), firstq.pair);
+ e.v1.getE(mid). bindTo(e.getBindingMatrix(firste), first);
+ e.v1.getE(mid).pair. bindTo(e.getBindingMatrix(firste), first.pair);
+ e.v2.getE(mid).pair. bindTo(e.getBindingMatrix(firste), firstq);
+ e.v2.getE(mid).pair.pair.bindTo(e.getBindingMatrix(firste), firstq.pair);
public E e1() { return e1; }
public E e2() { return e1.next; }
public E e3() { return e1.prev; }
public E e1() { return e1; }
public E e2() { return e1.next; }
public E e3() { return e1.prev; }
- public Vertex v1() { return e1.p1; }
- public Vertex v2() { return e1.p2; }
- public Vertex v3() { return e1.next.p2; }
- public Point p1() { return e1.p1.p; }
- public Point p2() { return e1.p2.p; }
- public Point p3() { return e1.next.p2.p; }
+ public Vertex v1() { return e1.v1; }
+ public Vertex v2() { return e1.v2; }
+ public Vertex v3() { return e1.next.v2; }
+ public Point p1() { return e1.v1.p; }
+ public Point p2() { return e1.v2.p; }
+ public Point p3() { return e1.next.v2.p; }
public boolean hasE(E e) { return e1==e || e1.next==e || e1.prev==e; }
public boolean has(Vertex v) { return v1()==v || v2()==v || v3()==v; }
public boolean hasE(E e) { return e1==e || e1.next==e || e1.prev==e; }
public boolean has(Vertex v) { return v1()==v || v2()==v || v3()==v; }