Code covered by the BSD License  

Highlights from
Rotate vector(s) about axis

5.0

5.0 | 2 ratings Rate this file 17 Downloads (last 30 days) File Size: 2.03 KB File ID: #34426

Rotate vector(s) about axis

by Ismail Hameduddin

 

03 Jan 2012 (Updated 03 Jan 2012)

Rotate three-dimensional vector(s) about a specified axis by a specified angle.

| Watch this File

File Information
Description

This is a very simple program that implements Rodrigues's rotation formula. Inputs are arrays of three-dimensional column or row vectors that are to be rotated about a specified axis by a specified angle. Output is array of rotated vectors with same dimension as input array.

Required Products MATLAB
MATLAB release MATLAB 7.12 (2011a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
03 Jan 2012 Jan Simon

This function has a H1 line and a compact and sufficient documentation of input, outputs, required subfunctions, date and contact address. The size of the input is checked.
Instead of "crosskv = v;" you can start with "crosskv(3) = ..." for the pre-allocation.
It would be nice, if the function accepts [N x 3] arrays also.
The function is small, but useful and usable.

03 Jan 2012 Ismail Hameduddin

Jan: Thanks for the comments. I used crosskv = v to handle both column as well as row vectors.

I updated the function to handle [N x 3] or [3 x N] arrays. I didn't originally want to do this because I wanted to avoid too many conditional statements but I think it comes in handy.

04 Jan 2012 Mukhtar Ullah

Very compact function that uses built-in functions. My quick and dirty solution to this was

M = makehgtform('axisrotate',k,theta);
v_rot = M(1:3,1:3)*v;

which looks cool but makehgtform is not a built-in function.

Please login to add a comment or rating.
Updates
03 Jan 2012

Added array/multiple vector functionality.

Tag Activity for this File
Tag Applied By Date/Time
aerospace Ismail Hameduddin 03 Jan 2012 08:53:00
image processing Ismail Hameduddin 03 Jan 2012 08:53:00
vector rotation Ismail Hameduddin 03 Jan 2012 08:53:00
kinematics Ismail Hameduddin 03 Jan 2012 08:53:00

Contact us at files@mathworks.com