Hi all,

My name is Aditya Bharti and I am extremely excited to be working with scipy over this summer. I am an undergraduate researcher in IIIT Hyderabad working on Computer Vision and Machine Learning. My work so far can be found here.

My project is to implement 3D Rotations in scipy with a representation-independent interface, in addition to some interesting and useful algorithms for rotation fitting. This introductory blog post will explain some key aspects of my project.

# What is a coordinate frame?

A coordinate frame is a system which uses one or more numbers, known as coordinates, to uniquely determine a position in space.

For the purposes of this project I will restrict myself to the familiar 3D Euclidean world. Each observer is free to choose any point as origin (0,0,0) and any 3 directions as the principal axes. Rotations are used to change between frames of references when the coordinate frames have the same origin.

# Understanding Rotations

## Rotations as Vector Transformations

The rotation transform applied to a point is easiest to visualize as the circular motion around an axis of rotation. This view of rotations as point transforms is less powerful than the next one under consideration.

## Rotations as Frame Transformations

The second way of viewing rotations is as relating coordinates in the final coordinate frame to the coordinates in the initial coordinate frame.

Consider the example of a 90 degree anti-clockwise rotation. Let C1 be the coordinate frame before rotation and let C2 be the coordinate frame after rotation. Consider this rotation applied to the vector (1, 0, 0) in frame C1.

- Application on points

The rotation can be thought of as simply rotating (1, 0, 0) [frame C1] about (0, 0, 0) to reach the new position (0, 1, 0) [frame C1]. - Relating frames

If we want to answer the question “what are the coordinates of point (1, 0, 0) [frame C2] in frame C1?” this approach to rotations is more powerful. The answer is obtained by simply applying the rotation to (1, 0, 0) to get point (0, 1, 0) in frame C1. Intuitively, this can be seen by rotating the coordinate axes by 90 degrees anti-clockwise and observing that the new x-axis coincides with the old y-axis.

# Representing rotations

Rotations can be represented in many different ways numerically

- Vectors: The new positions of the 3 axes are stored
- Discrete Cosine Matrices: Since a rotation is a linear transform, it can be represented as a matrix
- Euler Angles: Once the sequence of axes is fixed, three angles are all that are required to represent any rotation
- Axis-angle: Stores the direction of the axis of rotation and the angle by which to rotate
- Quaternions: Since the rotation matrices are orthogonal, they can be represented using just 4 numbers. This mathematical structure can be seen as an extension of a complex number and has many interesting properties.