Be the first to rate this file! 3 Downloads (last 30 days) File Size: 34.1 KB File ID: #37597

Efficient Vector Rotation Matrix Routine

by Darin Koblick

 

23 Jul 2012

Efficient Method to Determine a Matrix Needed to Rotate One Vector to Another

| Watch this File

File Information
Description

Suppose you have a unit vector described by f = [ai bj ck] and you would like to rotate f such that its result is t = [di ej fk]. This routine will find R(f,t) such that R(f,t)*f’ = t’. Where R(f,t) is known as the 3 x 3 transformation matrix needed to rotate f into t.

This MATLAB routine was based on a published article titled “Efficiently Building a Matrix to Rotate One Vector to Another” written by Tomas Moller and John Hughes in 1999.

This method features no square roots or trigonometric function calls and is reported to be faster than any other vector rotation matrix method tested by Moller and Hughes. In fact, the Goldman method (fastest method tested) was 50% slower than this routine in conversion speed tests.

Working Example:

Unit Vector f:
>> f = rand(1,3);
>> f = f./norm(f);

Unit Vector t:
>> t = rand(1,3);
>> t = t./norm(t);

The transformation matrix R(f,t) is found:
>> R = vecRotMat(f,t);

Now, test that R*f’= t’
>> R*f’

Required Products MATLAB
MATLAB release MATLAB 7.14 (R2012a)
Tags for This File  
Everyone's Tags
angles, euler, goldman, hughes, mathematics, matrix, moller, rotate, rotation, rotation matrix, vector
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
10 Jan 2013 Jan Simon

There is some potential for accelerations:
1. Avoid calculatin ~idx 35 times, but use a temporary variable instead.
2. Matlab's CROSS and DOT implementations are very slow, so better calculate them inlined.

Contact us