+
+ public Segment getSegment() { return new Segment(p1.getPoint(), p2.getPoint()); }
+
+ public void bindingGroupChanged(edu.berkeley.qfat.geom.BindingGroup newBindingGroup_) {
+
+ edu.berkeley.qfat.geom.BindingGroup<E> newBindingGroup =
+ (edu.berkeley.qfat.geom.BindingGroup<E>)newBindingGroup_;
+ if (newBindingGroup==null) return;
+ if (this==newBindingGroup.getMaster()) return;
+ HashSet<E> nbg = new HashSet<E>();
+ for(E eother : (Iterable<E>)newBindingGroup) nbg.add(eother);
+ for(E eother : nbg) {
+ if (next==null || prev==null) continue;
+ if (eother.next==null || eother.prev==null) continue;
+
+ if (next.isBoundTo(eother.pair.prev.pair) && !prev.isBoundTo(eother.pair.next.pair))
+ prev.bindTo(next.getBindingMatrix(eother.pair.prev.pair), eother.pair.next.pair);
+ if (!next.isBoundTo(eother.pair.prev.pair) && prev.isBoundTo(eother.pair.next.pair))
+ next.bindTo(prev.getBindingMatrix(eother.pair.next.pair), eother.pair.prev.pair);
+
+ /*
+ if (next.isBoundTo(eother.prev) && !prev.isBoundTo(eother.next))
+ prev.bindTo(next.getBindingMatrix(eother.prev), eother.next);
+ if (!next.isBoundTo(eother.prev) && prev.isBoundTo(eother.next))
+ next.bindTo(prev.getBindingMatrix(eother.next), eother.prev);
+ */
+ if (next.isBoundTo(eother.next) && !prev.isBoundTo(eother.prev))
+ prev.bindTo(next.getBindingMatrix(eother.next), eother.prev);
+ if (!next.isBoundTo(eother.next) && prev.isBoundTo(eother.prev))
+ next.bindTo(prev.getBindingMatrix(eother.prev), eother.next);
+ }
+
+ }
+
+ public float stretchRatio() {
+ Vertex nearest = error_against.nearest(midpoint());
+ float nearest_distance = midpoint().distance(nearest.p);
+ float other_distance =
+ (p1.p.distance(error_against.nearest(p1.p).p)+
+ p2.p.distance(error_against.nearest(p2.p).p))/2;
+ return nearest_distance/other_distance;
+ }