source: trunk/src/rotate_vector.m @ 1157

Last change on this file since 1157 was 1086, checked in by sommeria, 4 years ago

set_slice updated

File size: 737 bytes
Line 
1%calculate the components of the unit vector norm_plane normal to the plane
2%defined by the rotation vector PlaneAngle (in degree)
3% this gives the equation of the plane as norm_plane(1)x + norm_plane(2)y + norm_plane(2)z = 0
4
5function [X,Y,Z]=rotate_vector(PlaneAngle,x,y,z)
6M=rodrigues(PlaneAngle);
7
8X=M(1,1)*x+M(1,2)*y+M(1,3)*z;
9Y=M(2,1)*x+M(2,2)*y+M(2,3)*z;
10Z=M(3,1)*x+M(3,2)*y+M(3,3)*z;
11
12
13%
14% om=norm(PlaneAngle);%norm of rotation angle in degrees
15% OmAxis=PlaneAngle/om; %unit vector marking the rotation axis
16% cos_om=cos(pi*om/180);
17% sin_om=sin(pi*om/180);
18% coeff=OmAxis(3)*(1-cos_om);
19% norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om;
20% norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om;
21% norm_plane(3)=OmAxis(3)*coeff+cos_om;
Note: See TracBrowser for help on using the repository browser.