checkpoint
[anneal.git] / src / edu / berkeley / qfat / geom / HasBindingGroup.java
1 package edu.berkeley.qfat.geom;
2 import javax.media.opengl.*;
3 import java.util.*;
4
5 public abstract class HasBindingGroup {
6
7     BindingGroup bindingGroup;
8
9     // know:      self   = bindingGroup[self] * master
10     // know:      other  = other.bindingGroup[other] * other.bindingGroup.master
11     // want:      self   = bindingMatrix * other
12     // therefore: master = bindingGroup[self]^-1 * bindingMatrix * other
13     // therefore:        = bindingGroup[self]^-1 * bindingMatrix * other.bindingGroup[other] * other.bindingGroup.master
14     public void bindTo(HasBindingGroup other, Matrix bindingMatrix) {
15         if (other.bindingGroup == this.bindingGroup)
16             throw new Error("rebind attempt");
17
18         bindingMatrix =
19             getBindingMatrix()
20             .times(bindingMatrix)
21             .times(other.getBindingMatrix());
22         other.bindingGroup.merge(bindingGroup, bindingMatrix);
23     }
24
25     public Matrix getBindingMatrix() {
26         return bindingGroup.getMatrix(this);
27     }
28
29     public HasBindingGroup getMaster() {
30         return bindingGroup.getMaster();
31     }
32
33 }