Computer Science Canada 3D Rotation about arbitrary axis |
Author: | jondmml [ Fri Jun 08, 2007 3:23 pm ] |
Post subject: | 3D Rotation about arbitrary axis |
Hi, I have been working on 3D rotation and have been able to implement rotation about an arbitrary axis by translating, rotating, then translating. However, I wish to be able to rotate about an axis that does not consist of direction vectors in the x, y, and z directions. This is because my object can be rotated and I wish to then rotate a portion of the object relative to the object and not to the original axis. My idea is to first translate the object relative to (0,0,0), then rotate the object back into its original location, THEN rotate the object as much as necessary. Then I would reverse all of the previous moves to move the object back to its original location. However, there are a couple problems with this plan. First, it will become a very complex and time consuming operation. Secondly, I do not know how much I must rotate the object to return it to its original location as it has been rotated several times about the x and y axis (I do not know how to combine these rotations). Hopefully you have followed what I've written so far. If anyone has ever done something like this or has any idea how I could solve this problem, your help is appreciated! There might be a much better method by which to do this that I do not know about. I do not want to use matrices as I have not had much experience with them and as this is part of a project, I don't think I have the time to learn all there is to know or to rewrite my current problem. Thanks again for the help, Jon |
Author: | Mazer [ Fri Jun 08, 2007 3:27 pm ] |
Post subject: | RE:3D Rotation about arbitrary axis |
I'll admit I haven't read through the whole thing (if this doesn't work, I don't know enough to help anyways!), but have you looked into quaternions? |
Author: | jondmml [ Fri Jun 08, 2007 3:46 pm ] |
Post subject: | Re: 3D Rotation about arbitrary axis |
Well I've seen it as I've looked through different pages. But it looks like more a lot of new material that I've never learned about and it looks impractical for me to learn in a short period of time. But thanks anyway for the response. |
Author: | Saad [ Fri Jun 08, 2007 3:48 pm ] |
Post subject: | Re: 3D Rotation about arbitrary axis |
Heres where I learned arbritary axis rotation http://local.wasp.uwa.edu.au/~pbourke/geometry/rotate/ Quote: Rotation of a point in 3 dimensional space by theta about an arbitrary axes defined by a line between two points P1 = (x1,y1,z1) and P2 = (x2,y2,z2) can be achieved by the following steps
(1) translate space so that the rotation axis passes through the origin (2) rotate space about the x axis so that the rotation axis lies in the xz plane (3) rotate space about the y axis so that the rotation axis lies along the z axis (4) perform the desired rotation by theta about the z axis (5) apply the inverse of step (3) (6) apply the inverse of step (2) (7) apply the inverse of step (1) Basically to find how much to rotate it by i applied rotation on the axis, From there you can find x,y,z facing which is the amount you want to rotate it by. Note you need to learn about vectors For example Consider Z = Depth To get X Facing you get the arccosd() of the Dot Product between (0,0,1) and the unit Z-axis vector(You make the X of the vector 0 before normalizing). To get Y Facing you get the arccosd() of the Dot Product between (1,0,0) and the unit Z-axis vector(You make the Y of the vector 0 before normalizing). This gives the angle between the vectors so you can find out how much to rotate by. If you still dont understand you may want to look on the webiste Saad |
Author: | zylum [ Fri Jun 08, 2007 9:36 pm ] | ||
Post subject: | Re: 3D Rotation about arbitrary axis | ||
If you are using rotation matrices then you can use this matrix to rotate about the arbitrary axis A:
where c and s are cos(theta) and sin(theta) |
Author: | jondmml [ Sat Jun 09, 2007 3:46 pm ] |
Post subject: | RE:3D Rotation about arbitrary axis |
I tried implementing what a100 mentioned however it does not always rotate the object back to its correct position along the axis. I also believe my arccosd function is not perfect as I am running Turing 4.0.4 which does not have arccosd built in and had to use the conversion formula in the turing help file. This conversion formula does not work for numbers such as acos(-1) as it returns 0 not 180 and there sometimes exists division by zero errors. In summary, does anyone have a working arccosd function? Hopefully this will help to eliminate some errors. |
Author: | Saad [ Sun Jun 10, 2007 9:13 am ] | ||
Post subject: | Re: RE:3D Rotation about arbitrary axis | ||
jondmml @ Sat Jun 09, 2007 3:46 pm wrote: I tried implementing what a100 mentioned however it does not always rotate the object back to its correct position along the axis. I also believe my arccosd function is not perfect as I am running Turing 4.0.4 which does not have arccosd built in and had to use the conversion formula in the turing help file. This conversion formula does not work for numbers such as acos(-1) as it returns 0 not 180 and there sometimes exists division by zero errors.
In summary, does anyone have a working arccosd function? Hopefully this will help to eliminate some errors. Here is the ArcCosd function
|
Author: | zylum [ Wed Jun 13, 2007 10:54 am ] | ||
Post subject: | RE:3D Rotation about arbitrary axis | ||
if you've done matrix multiplication in discrete i suggest you use the matrix method as it is less computationally intensive. you just multiply the rotation matrix by the position matrix which is just your position vector as a columns like so:
the resulting matrix is another column vector of your transformation. if you havent learned it yet i suggest googling it.. its really quite east. its just multiplication and addition of certain elements in one matrix with the other. |
Author: | jondmml [ Wed Jun 13, 2007 5:48 pm ] |
Post subject: | RE:3D Rotation about arbitrary axis |
It's funny.. I'm pretty much finished the course and all we've done is a bit of changing matrices to reduced row echelon form... so really not much at all. But I will definitely look it up. If it doesnt require too much work I might just do everything with matrices. |