http://www.mathworks.com/matlabcentral/newsreader/view_thread/293214
MATLAB Central Newsreader  Rotate a cube?
Feed for thread: Rotate a cube?
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Wed, 06 Oct 2010 08:58:05 +0000
Rotate a cube?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/293214#785528
Nguyen Long
I have a cube with 8 vertexes (know exactly coordinate of each vertex).<br>
But the problem is "How to rotate this cube around its edge or a fixed axe?"<br>
Can you give me any hints or give me an example code for solving this problem.<br>
Thank you. <br>
PS: I'm the beginner in Matlab, so I really need your help

Thu, 07 Oct 2010 03:17:03 +0000
Re: Rotate a cube?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/293214#785793
Roger Stafford
"Nguyen Long" <nguyenlongvp@gmail.com> wrote in message <i8hdmt$lup$1@fred.mathworks.com>...<br>
> I have a cube with 8 vertexes (know exactly coordinate of each vertex).<br>
> But the problem is "How to rotate this cube around its edge or a fixed axe?"<br>
> Can you give me any hints or give me an example code for solving this problem.<br>
> Thank you. <br>
> PS: I'm the beginner in Matlab, so I really need your help<br>
        <br>
The following is a partial answer. Let W be a unit vector pointing along the positive (righthand rule) axis of rotation, let R be a point somewhere on this axis, let P be a point to be rotated about the axis by an angle theta, and let Q be that point after rotation. Then in vector analysis you have:<br>
<br>
PR = PR;<br>
C = cross(PR,W);<br>
Q = R + W*dot(PR,W) + cross(W,C)*cos(theta) + C*sin(theta);<br>
<br>
Can you see why?<br>
<br>
Now apply this to the vertices of your cube.<br>
<br>
Roger Stafford

Thu, 07 Oct 2010 05:47:04 +0000
Re: Rotate a cube?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/293214#785805
Nguyen Long
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i8je3f$evk$1@fred.mathworks.com>...<br>
> "Nguyen Long" <nguyenlongvp@gmail.com> wrote in message <i8hdmt$lup$1@fred.mathworks.com>...<br>
> > I have a cube with 8 vertexes (know exactly coordinate of each vertex).<br>
> > But the problem is "How to rotate this cube around its edge or a fixed axe?"<br>
> > Can you give me any hints or give me an example code for solving this problem.<br>
> > Thank you. <br>
> > PS: I'm the beginner in Matlab, so I really need your help<br>
>         <br>
> The following is a partial answer. Let W be a unit vector pointing along the positive (righthand rule) axis of rotation, let R be a point somewhere on this axis, let P be a point to be rotated about the axis by an angle theta, and let Q be that point after rotation. Then in vector analysis you have:<br>
> <br>
> PR = PR;<br>
> C = cross(PR,W);<br>
> Q = R + W*dot(PR,W) + cross(W,C)*cos(theta) + C*sin(theta);<br>
> <br>
> Can you see why?<br>
> <br>
> Now apply this to the vertices of your cube.<br>
> <br>
> Roger Stafford<br>
<br>
What W mean?

Thu, 07 Oct 2010 05:59:05 +0000
Re: Rotate a cube?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/293214#785808
Nguyen Long
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i8je3f$evk$1@fred.mathworks.com>...<br>
> "Nguyen Long" <nguyenlongvp@gmail.com> wrote in message <i8hdmt$lup$1@fred.mathworks.com>...<br>
> > I have a cube with 8 vertexes (know exactly coordinate of each vertex).<br>
> > But the problem is "How to rotate this cube around its edge or a fixed axe?"<br>
> > Can you give me any hints or give me an example code for solving this problem.<br>
> > Thank you. <br>
> > PS: I'm the beginner in Matlab, so I really need your help<br>
>         <br>
> The following is a partial answer. Let W be a unit vector pointing along the positive (righthand rule) axis of rotation, let R be a point somewhere on this axis, let P be a point to be rotated about the axis by an angle theta, and let Q be that point after rotation. Then in vector analysis you have:<br>
> <br>
> PR = PR;<br>
> C = cross(PR,W);<br>
> Q = R + W*dot(PR,W) + cross(W,C)*cos(theta) + C*sin(theta);<br>
> <br>
> Can you see why?<br>
> <br>
> Now apply this to the vertices of your cube.<br>
> <br>
> Roger Stafford<br>
<br>
Thanks. The W vector can be obtain by normalization one vector on the rotate axis, is that true? and your formula is a part of Rodrigues' rotation matrix?

Thu, 07 Oct 2010 08:00:22 +0000
Re: Rotate a cube?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/293214#785823
Roger Stafford
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i8je3f$evk$1@fred.mathworks.com>...<br>
> ......<br>
> PR = PR;<br>
> C = cross(PR,W);<br>
> Q = R + W*dot(PR,W) + cross(W,C)*cos(theta) + C*sin(theta);<br>
> .......<br>
         <br>
I'm afraid I got that rotation in the wrong direction. As it is, it is doing a left hand rotation as theta increases, rather than a right hand one. My apologies. It should read:<br>
<br>
PR = PR;<br>
C = cross(W,PR);<br>
Q = R + W*dot(PR,W) + cross(C,W)*cos(theta) + C*sin(theta);<br>
<br>
Roger Stafford

Thu, 07 Oct 2010 09:56:08 +0000
Re: Rotate a cube?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/293214#785858
Nguyen Long
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i8jumm$sqj$1@fred.mathworks.com>...<br>
> "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i8je3f$evk$1@fred.mathworks.com>...<br>
> > ......<br>
> > PR = PR;<br>
> > C = cross(PR,W);<br>
> > Q = R + W*dot(PR,W) + cross(W,C)*cos(theta) + C*sin(theta);<br>
> > .......<br>
>          <br>
> I'm afraid I got that rotation in the wrong direction. As it is, it is doing a left hand rotation as theta increases, rather than a right hand one. My apologies. It should read:<br>
> <br>
> PR = PR;<br>
> C = cross(W,PR);<br>
> Q = R + W*dot(PR,W) + cross(C,W)*cos(theta) + C*sin(theta);<br>
> <br>
> Roger Stafford<br>
<br>
But rotate anticlockwise is often used in physics and maths, rotate to the right handside is correct?