Rotating a cube in spaceDate: Mon, 5 Dec 1994 20:55:39 +0300 From: Dave Bentz Subject: equations for rotating a cube in space on computer I am a high school teacher, with a student interested in writing a program to show a cube on the screen and then rotate it by moving the corners around. He is rather vague on how he plans to do this but has asked me for equations. I don't have any. How about you? Date: 6 Dec 1994 22:16:43 GMT From: Dr. Math Organization: Swarthmore College Subject: Re: equations for rotating a cube in space on computer Hello there! The concept of rotating a collection of points in space is closely related to the concept of mulitplying ordered triplets (the coordinates of the points in space, and sometimes we call these ordered triplets VECTORS) and matrices. In particular, if you multiply a collection of points by a matrix whose determinant is 1, and whose columns have another nice property we call "othonormal." What this means, and I'm not sure how much of this you'll understand, is that the rows of the matrix are vectors that have length 1 (the length of a vector (a,b,c) is the square root of (a^2 + b^2 + c^2)) and are such that if you multiply any two rows together, you get zero. This last property is called "orthogonality", and it basically just means that the rows are vectors that are perpendicular to each other. Matrices like this are called Orthogonal Matrices or Rotation Matrices. If you do this multiplication, you'll obtain a new collection of points that looks like the old set of points, but rotated around. So for example, let's say we have the cube which has the points (0,0,0) (0,1,0) (0,1,1) (0,0,1) (1,0,0) (1,1,0) (1,1,1) (1,0,1) as its vertices. The let's say we have the following rotation matrix: 1/Sqrt{2} 0 1/Sqrt{2} 0 1 0 -1/Sqrt{2} 0 1/Sqrt{2} Notice that the determinant of this matrix is one. Do you know how to multiply a 3x3 matrix by an ordered triplet? Here's how you do it. I'll use the last ordered triplet in the list, (1,0,1). You write the matrix on the left, and the vector (the ordered triplet) vertically on the right, like this: 1/Sqrt{2} 0 1/Sqrt{2} 1 0 1 0 x 0 -1/Sqrt{2} 0 1/Sqrt{2} 1 Then you multiply each row in the matrix by the vector, like this: 1/Sqrt{2} 0 1/Sqrt{2} 1 1/Sqrt{2}*1 + 0*0 + 1/Sqrt{2}*1 0 1 0 x 0 = 0*1 + 1*0 +0*1 -1/Sqrt{2} 0 1/Sqrt{2} 1 -1/Sqrt{2}*1 + 0*0 + 1/Sqrt{2}*1 So the result of this multiplication is the ordered triplet (Sqrt{2}, 0, 0). Can you see how you would multiply the matrix by the other ordered triplets? If you'd like help constructing other rotation matrices, just let us know. I hope this helps you! |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. Math^{TM}
© 1994-2013 The Math Forum
http://mathforum.org/dr.math/