+
+ private M binding = new M();
+ private P bound_to = this;
+
+ public void unbind() { bound_to = null; binding = null; }
+ public void bind(P p) { bind(p, new M()); }
+ public void bind(P p, M binding) {
+
+ P px = p;
+ do {
+ if (px==this) return; // already bound
+ px = px.bound_to;
+ } while(px != p);
+
+ P temp_bound_to = p.bound_to;
+ M temp_binding = p.binding;
+ p.bound_to = this.bound_to;
+ p.binding = binding.times(this.binding); // FIXME: may have order wrong here
+ this.bound_to = temp_bound_to;
+ this.binding = temp_binding.times(temp_binding); // FIXME: may have order wrong here
+ }
+
+ public void move(V v) {
+ P p = this;
+ do {
+ p.x = p.x+v.x;
+ p.y = p.y+v.y;
+ p.z = p.z+v.z;
+ v = v.times(binding);
+ p = p.bound_to;
+ } while (p != this);
+ }
+