 Structural Bioinformatics Library Template C++ / Python API for developping structural bioinformatics applications.
User Manual # Rotation_3

Authors: F. Cazals and T.O'Donnell

# Introduction

There are several ways to define and parameterize 3D rotations, see e.g. Wiki/rotation in 3D and Wiki/rotation matrix :

• Euler angles: the rotation is decomposed into three simpler rotations
• Angle-axis: the rotation is parameterized by a rotation around an arbitrary axis. (Nb: the set of all rotations is typically referred to as the -ball.)
• Matrices representing the special orthogonal group SO(3).
• Quaternions, which generalize complex numbers in 3D.

This package provides various parameterization of rotations using these formalisms, using low level classes from Eigen.

# Implementation and functionalities

The reader is referred to  as well as rotations 3D formalism and rotation matrix .

We also note in passing that there exist various metrics between 3D rotation, see  and  .

# Design and classes

3D Rotations are performed on points trough a single overloaded functor templated by a number type: SBL::GT::T_Rotation_3

This class takes in as input from one to three angular radii values followed by the same number of orthogonal axes around which the corresponding rotations are applied. If no axes are given the unity vectors x y and z are used by default(in this order). Varying representations of 3 dimensional rotation can be obtained through methods of SBL::GT::T_Rotation_3:

• Quaternions (Eigen::Quaternion<NT>)
• Angle and axis(Eigen::AngleAxis<NT>)
• 3D rotation matrix(Eigen::Matrix<NT,3,3>)

The functor operator needs an iterator input for points and an iterative output to apply the rotation directly. Finally if on top of all the previous parameters a center of rotation is supplied then the points will be centered before rotation is applied.

# Examples

The following examples shows how to rotate a set of randomly drawn 3D points:

#include <SBL/GT/Rotation_3.hpp>
#include <math.h>
#include <vector>
#include <iostream>
int main(int argc, char *argv[])
{
std::vector<Eigen::Matrix<float,3,1>> points(10);
std::vector<Eigen::Matrix<float,3,1>> rotated_points;
rotated_points.reserve(10);
for(unsigned i=0;i<points.size();i++)
{
points[i]=static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
points[i]=static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
points[i]=static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
}
SBL::GT::T_Rotation_3<std::vector<Eigen::Matrix<float,3,1>>::iterator,float,std::back_insert_iterator< std::vector<Eigen::Matrix<float,3,1>>>> rot;
std::back_insert_iterator< std::vector<Eigen::Matrix<float,3,1>>> back (rotated_points);
rot(points.begin(),points.end(),M_PI/2,M_PI/2,M_PI/2,back);
for(unsigned i=0;i<points.size();i++)
std::cout << "original:" <<std::endl <<points[i] << " " << points[i] << " " << points[i] << " " << std::endl
<< "rotated:" <<std::endl << rotated_points[i] << " " << rotated_points[i] << " " << rotated_points[i] <<std::endl;
return 0;
}
static 3d rotation methods.
Definition: Rotation_3.hpp:36