float halfup = 0;
translations = new Matrix[] {
+
Matrix.translate(new Vec(lshift, depth, halfup)),
- /*
Matrix.translate(new Vec(rshift, depth, halfup)),
+ /*
Matrix.translate(new Vec(lshift, -depth, halfup)),
Matrix.translate(new Vec(rshift, -depth, halfup)),
*/
return e.comparator() > comparator() ? 1 : -1;
}
public void bindEdge(E e, Matrix m) {
+ _bindEdge(e, m);
+ pair._bindEdge(e.pair, m);
+ }
+ public void _bindEdge(E e, Matrix m) {
//bind_to.add(e);
- //assumes edges are identical length at binding time
e = e.pair;
+ /*
+ //assumes edges are identical length at binding time
Vec reflectionPlaneNormal = e.p2.p.minus(e.p1.p).norm();
float a = reflectionPlaneNormal.x;
float b = reflectionPlaneNormal.y;
-2*a*b, 1-2*b*b, -2*b*c, 0,
-2*a*c, -2*b*c, 1-2*c*c, 0,
0, 0, 0, 1);
- /*
m = m.times(Matrix.translate(e.midpoint().minus(Point.ORIGIN))
.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));
+ */
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();
this.bindTo(m, e);
}
public void merge(BindingGroup<T> bg, Matrix m) {
+ if (bg==this) throw new Error();
for(HasBindingGroup hbg : bg.matrices.keySet()) {
matrices.put((T)hbg, bg.matrices.get(hbg).times(m));
hbg.bindingGroup = this;
if (other.bindingGroup == null) other.bindingGroup = new BindingGroup(other);
if (other.bindingGroup == this.bindingGroup) {
- if (getBindingMatrix(other).equals(bindingMatrix)) return;
+ if (getBindingMatrix(other).equals(bindingMatrix))
+ return;
throw new Error("rebind attempt: "+this+" and "+other+" with "
+ bindingMatrix
+ "; expected "
}
bindingMatrix =
- getBindingMatrix()
+ getBindingMatrix().inverse()
.times(bindingMatrix)
.times(other.getBindingMatrix());
other.bindingGroup.merge(bindingGroup, bindingMatrix);
near(p,z.p);
}
private static final float EPSILON = 0.001f;
- private static boolean near(float a, float b) { return a==b; }
+ private static boolean near(float a, float b) { return Math.abs(a-b)<EPSILON; }
public int hashCode() {
return