Work Product Summary

So after three months of working, it is now time to gather my thoughts and look back on what I’ve achieved. This brief post will also serve as a work product submission link.

First things first, all my merged changes live here as a new scipy.spatial.transform submodule. As of writing, the package include the following functionality:

  1. The Rotation class:
    1. Initialize a rotation from quaternion, direction cosine matrix, euler angles or rotation vector.
    2. Allows a user to convert freely between any of the above representations.
    3. Supports composition and inversion as operations on rotations.
    4. Supports application of rotations on points / vectors.
    5. Also contains a method of estimating the rotation between two frames of observation.
  2. The Slerp class:
    1. Spherical linear interpolation of rotations. Essentially the shortest path of constant angular velocity between keyframes rotations.

There is a single outstanding pull request for the RotationSpline class, which will implement cubic spline interpolation of rotations and rename Slerp to RotationSlerp to logically separate them from the generic spline and slerp methods.

Once this pull request has been finalized, I will also write a tutorial for the whole spatial.transform package as an introduction on how to work with rotations.

Do go through the Rotation class documentation to get a general idea of the usage of the class. (Documentation links are only finalised after every release of scipy, so take a look at the developer documentation for now).

Interpolations, matching and more

Now that a major chunk of the work has been done, I am making pull requests directly into the main scipy repository. This next phase of the project consitsts of rotation estimation and interpolations.

Wahba’s problem

Wahba’s problem is figuring out the rotation that maps one frame to another. Given a set of vector observations in two different frames, the new `Rotation.match_vectors` function returns the best estimate of the rotation that maps one to the other. This is often used to determine the orientation of spacecraft which only have stationary distant stars as reference.

The implementation will be completed within the next week and merged into the main repository.

Error bound based on input noise

While the estimation itself was pretty simple (the SVD method has been used for estimation) the major chunk of the work involved reading papers and figuring out how to give the user and estimate of the ‘correctness’ of the returned rotation. For this purpose, we also return a sensitivity matrix which is the [scaled] covariance matrix of the three component error vector expressed as a rotation of the initial frame.

I realise that’s a mouthful. In simple terms, the attitude error along each axes is treated as a random variable and the covariance matrix of these 3 random variables is computed.


Another useful aspect of having a rotation module is the ability to interpolate between orientation without having to specify all of them. This can easily be useful for 3D animation and simulations.

Two kinds of interpolations are supported:

Spherical Linear Interpolation

This is the ‘shortest-path’ equivalent along a 3D sphere. This leads to an orientation change with constant velocity between two successive keyframes.

Unfortunately, this often leads to a jerky motion at the keyframe endpoints when the angular velocity suddenly changes and the alternative is often preferred.

Spline Interpolation

Instead of using a linear function for interpolation, a spline (a polynomial of degree 3) is used. This has the additional benefits that we can choose the interpolation polynomial so as to ensure a continuous change in the angular velocity and acceleration at all times during the interpolation. This does not lead to the shortest path, but leads to an overall smooth orientation change.

This PR will also be merged in the coming week.

Next steps

As we head into these last few days of GSoC I plan to complete the two remaining pull requests and write a tutorial show casing the capabilities of this new module. Stay tuned!