Xref: utzoo rec.games.programmer:3380 alt.msdos.programmer:2552 comp.os.msdos.programmer:4559 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!ucsd!ucbvax!tut.cis.ohio-state.edu!anaconda.cis.ohio-state.edu!meekins From: meekins@anaconda.cis.ohio-state.edu (timothy lee meekins) Newsgroups: rec.games.programmer,alt.msdos.programmer,comp.os.msdos.programmer Subject: Re: 3D rotation update Keywords: 3D, rotation, real, thanks Message-ID: <106072@tut.cis.ohio-state.edu> Date: 11 Apr 91 00:54:13 GMT References: <1991Apr10.191212.5249@lynx.CS.ORST.EDU> Sender: news@tut.cis.ohio-state.edu Followup-To: rec.games.programmer Organization: The Ohio State University, Department of Computer and Information Science Lines: 59 In article <1991Apr10.191212.5249@lynx.CS.ORST.EDU> murrayk@prism.CS.ORST.EDU writes: >I can draw and rotate an object on the screen around the x, y and z-axis >all day long. The only problem is that each axis that I rotate >around is the corresponding axis of the monitor (what you actually see). >Now, what I want to do is to be able to rotate the object around its own >three axes (virtual axes). For example, say the object is a tetrehedron >with its base in the xy plane (the yz plane is sticking in your face) and >its top point in your face. The object is situated so that the z-axis is a >line running though the top point and the middle of the base. Now say that >I rotate this object around the x axis about 30 degrees so that the point >is now partially up the screen. Now if I was to rotate the object about >the z-axis as my code now exists, the top point of the tetrehedron would >sweep out a circle on the screen. This problem could be solved by doing >the rotations in a certain order, but that screws up as soon as you rotate >about the third axis. What the object should do if it is rotated about the >z-axis (its z-axis) would be to spin along the imaginary line running >though its top point and its base. But alas, I cannot get this to happen. > >In consulting a few graphical technique books, I found out exactly how to >do a rotation about an arbitrary line. I figured that if I kept the axes >of the object in the data of the object itself and rotated the axes along >with the object, then I would be able to do an arbitrary rotation about >those axes and voila, it would work. I tried this and have had no luck. >My code has been gone over with a fine toothed comb (my own and a friends) >and no problem can be found. > Rotating about an arbitray axis is a simple thing, but as you have noticed, it is not the solution to your problem. >If anyone has experience in this area of 3D rotation, please keep posting. >If I am just missing a small point, don't flame me. I will see it soon >enough. I am bound to find out what I am missing eventually. All your >help is appreciated. Well, you're not missing a small point. You are most likely experiencing gimbal lock, a term developed in aeronautical engineering (I believe) when using euler angles (x,y,z rotations). Your description of ordering the rotations to make it work about one axis and a different rotation ordering for axis definately sounds a like the euler angle problem. I would suggest that you use Quaternions instead of Euler angles. Basically, you convert your 3 rotations into 4-D space, perform the rotation, then map back. But, a better method would be to learn directly how quaternions work and not even perform the mapping. In which case, you specify the axis of rotation. For more information, see "Animating Rotation with Quaternion Curves" in SIGGRAPH '85 proceedings. Source code for quaternions is provided with Graphics Gems by Andrew Glassner and is available by FTP somewhere. -tim -- +---------------------------S-U-P-P-O-R-T-----------------------------------+ |/ Tim Meekins <<>> Snail Mail: <<>> Apple II \| |> meekins@cis.ohio-state.edu <<>> 8372 Morris Rd. <<>> Forever! <| |\ timm@pro-tcc.cts.com <<>> Hilliard, OH 43026 <<>> /|