|
Page 3 of 6
Resolving Constraints
When resolving a distance constraint for a bone, we have two end points and the constrained length between them. End point will be base of the current bone. End point will be the base of the child bone. Length will be the desired distance between and . We will also support positive relaxation weights, and , corresponding to the end points. The higher an endpoint is weighted, the more that endpoint will move in the solution. If an endpoint is given a zero weight, it will not move at all. If both end points are given the same weight, they will move equal distances.
As a first step, we can check the bone weights for a cases that implies we shouldn't do any work. If the total weight, , is zero neither joint should move and the constraint is skipped.
Next we check if the squared distance between the end points is zero. Let and then use the dot product to get the squared distance. If the result is zero, it implies that the end points are directly on top of each other. This makes it a bit hard to choose the best direction for stretching the bones. We will instead skip constraints in this situation with the hope that either later in this iteration or on a following iteration the points will be stretched apart by one of the neighboring constraints being resolved.
Now that we have found a constraint to modify, we need to compare the distance between the end points with the given bone length . The distance between and can be calculated as .
We need to adjust the current distance by . We can now compute a vector that would move the appropriate distance from by normalizing , and rescaling it to the desired change in distance, . This gives us a new vector .
Rather than directly adding to , we want to distribute it across and based on the relaxation weights. Note that when modifying we will be subtracting to move the endpoint in the opposite direction.
To distribute the weighted modification across both joints, we will use the following equations.


Our joints are now at the appropriate distance and the constraint has been resolved.
|