  ## Solving the angle problem: How to find the rotation between two vectors.

This solution is implemented in the Math class and will be invoked by the bezier curve-following IK method in the SkeletonNode class.

Given two normalised vectors, the cosine of the angle between them can be found using the dot product:

```quat rotation(vec3 v1, vec3 v2)
{
// v1 dot v2 = |v1| * |v2| * angle_cos
// If the vectors are normalised, their magnitudes will be '1', and so:
v1 = normalise(v1)
v2 = normalise(v2)
float angle_cos = dot(v1, v2)
...
```

The rotation axis can be found using the cross product of both vectors:

```...rotation() cont'd...
vec3 axis = normalise(cross(v1, v2))
...
```

## Optimal forms for creating quaternion:

Naive rotation() method (ignoring special cases such as angle=0):

```...rotation() cont'd...
float angle = acos(angle_cos)
return quaternion_from_axisangle(angle, axis)
}
```

The quaternion_from_axisangle() function likely uses trigonometry (such as the cosine function) to convert the given ...

## Generating a Bézier curve

Let's draw a Bézier, yeah!

## B-spline IK method outline

Make a B-spline (a composition of Bézier curves) of length equal to armature length. Place bones at lengths down the spline. Blender offers it as an option and the Blender documentation suggests it as being apt for organic bone structures such as spines. It would work well for my demo dragon character's long neck.

Definition of a parameterised curve in the 3D environment:
p = P(s) where p is 3D point in space where the curve lies at that distance, s.

Of course the bone distance would be defined by short jumps, not curved distances (it is discrete). It would seem that it is more complicated to map it to the continuous curve function, then, unless the curve can be discretised too.

## Armature curve-following method outline

If each bone's reach can be thought of as being contained within a sphere of a certain radius ...

## IK Constraints

[24/04/14 14:49]

Right, the IK is good enough for the model. Making test bind pose with basic "neck" armature in a curved pose like the eventual dragon model. A few constraints should make its movement look natural even without rotation.

To Blender!

Update: rotation works now.

[24/04/14 16:29]

Constraints for each joint should be defined relative to their parent joint, but how should they be defined in particular? The current IK solver doesn't allow "roll" motion for the joints, but each joint still has yaw and pitch rotation. Each joint could therefore specify a bounds, for example: yaw_max, yaw_min, pitch_max, pitch_max.

In the phoxtrace (Update: now "CharSim") IK solver, each frame the best incremental rotation is calculated for each joint in the form of a quaternion based on an axis and rotation. It may be necessary to convert the ...

## IK Constraints

[24/04/14 14:49]

Right, the IK is good enough for the model. Making test bind pose with basic "neck" armature in a curved pose like the eventual dragon model. A few constraints should make its movement look natural even without rotation.

To Blender!

Update: rotation works now.

[24/04/14 16:29]

Constraints for each joint should be defined relative to their parent joint, but how should they be defined in particular? The current IK solver doesn't allow "roll" motion for the joints, but each joint still has yaw and pitch rotation. Each joint could therefore specify a bounds, for example: yaw_max, yaw_min, pitch_max, pitch_max.

In the phoxtrace (Update: now "CharSim") IK solver, each frame the best incremental rotation is calculated for each joint in the form of a quaternion based on an axis and rotation. It may be necessary to convert the ...

## Inverse kinematics: IK solvers

Looking at IK (Inverse Kinematics) solving techniques for interactive armature animation. IK works well in games when interacting with a non-branching chain of joints, say an NPC's arm. In the case of my demo character, the dragon's neck is a perfect example of where some form of IK can make a rigged character interactive.

[16/04/14 14:08]