Code covered by the BSD License  

Highlights from
3D Rotation about Shifted Axis

5.0

5.0 | 1 rating Rate this file 31 Downloads (last 30 days) File Size: 2.49 KB File ID: #30864

3D Rotation about Shifted Axis

by Matt J

 

26 Mar 2011 (Updated 05 Jul 2011)

Computes/applies rotation about arbitrary 3D line.

| Watch this File

File Information
Description

Generates the roto-translation matrix for the rotation around an arbitrary line in 3D. The line need not pass through the origin. Optionally, also, applies this transformation to a list of 3D coordinates.
 
SYNTAX 1:
 
     M=AxelRot(deg,u,x0)
 
 
 in:
 
   u, x0: 3D vectors specifying the line in parametric form x(t)=x0+t*u
          Default for x0 is [0,0,0] corresponding to pure rotation (no shift).
          If x0=[] is passed as input, this is also equivalent to passing x0=[0,0,0].
 
   deg: The counter-clockwise rotation about the line in degrees. Counter-clockwise is defined using the
        right hand rule in reference to the direction of u.
 
 
 out:
 
  M: A 4x4 affine transformation matrix representing
     the roto-translation. Namely, M will have the form
  
                  M=[R,t;0 0 0 1]
    
      where R is a 3x3 rotation and t is a 3x1 translation vector.
  
 
 
SYNTAX 2:
 
        [R,t]=AxelRot(deg,u,x0)
 
Same as Syntax 1 except that R and t are returned as separate arguments.
  
 
 
SYNTAX 3:
 
This syntax requires 4 input arguments be specified,
 
    [XYZnew, R, t] = AxelRot(XYZold, deg, u, x0)
  
where the columns of the 3xN matrix XYZold specify a set of N point coordinates in 3D space. The output XYZnew is the transformation of the columns of XYZold, i.e., the original coordinates rotated appropriately about the axis. All other input/output arguments have the same meanings as before.
 

MATLAB release MATLAB 7.11 (2010b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
07 Jun 2011 pink

how to use?
thanks

07 Jun 2011 Matt J

@pink, you might want to explain to me what you're trying to do. I can't tell what elaboration of the help documentation you're looking for.

09 Aug 2011 Melissa

Can I use this to take a set of 3d cylinder cartesian coordinates and make a profile of polar coordinates by each slice of the cylinder?
Check this: http://www.mathworks.com/matlabcentral/answers/13398-cartesian-to-polar for more details of what I need.

09 Aug 2011 Matt J

@Melissa - You can use SYNTAX 3 to undo the tilt in your cylinder, assuming you already know its tilted z-axis, Ztilt. The cylinder becomes untilted when you rotate it about the rotation axis

 u=cross(Ztilt/norm(Ztilt), [0 0 1])

by a rotation angle of deg=asind(u).

27 Feb 2012 Melissa

How do I find a tilted axis so that I can use this?

27 Feb 2012 Matt J

@Melissa - finding the axis of your cylinder, if you don't already know it, is a data fitting problem. You should probably pose that question in the Newsgroup, since it doesn't concern this FEX submission directly.

06 Mar 2012 Melissa  
Please login to add a comment or rating.
Updates
30 Mar 2011

Clarified description and help doc only. No new code.

05 Jul 2011

Added option to transform a set of coordinates.

Tag Activity for this File
Tag Applied By Date/Time
rotation matrix Matt J 28 Mar 2011 11:41:34
rotation Matt J 31 Mar 2011 01:50:08
affine Matt J 31 Mar 2011 01:50:08
affine transform Matt J 31 Mar 2011 01:50:08
robotics Matt J 31 Mar 2011 09:41:40
motion Matt J 31 Mar 2011 09:42:02
rodrigues Matt J 31 Mar 2011 21:46:31
rodrigues formula Matt J 31 Mar 2011 21:46:31
rodrigues rotation formula Matt J 31 Mar 2011 21:47:11
axis Matt J 01 Apr 2011 14:38:17

Contact us at files@mathworks.com