home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.graphics
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!destroyer!ubc-cs!alberta!leung
- From: leung@cs.UAlberta.CA (Jian-Dong Liang)
- Subject: Re: 3d rotation about an arbitrary axis: how?
- Message-ID: <1992Aug31.174635.14572@cs.UAlberta.CA>
- Sender: news@cs.UAlberta.CA (News Administrator)
- Nntp-Posting-Host: newsarepta.cs.ualberta.ca
- Organization: University of Alberta
- References: <87331@netnews.upenn.edu>
- Date: Mon, 31 Aug 1992 17:46:35 GMT
- Lines: 37
-
- In article <87331@netnews.upenn.edu> ledogar@eniac.seas.upenn.edu (Charles Ledogar) writes:
- >My visualization package now needs a flight-simulator-like viewpoint
- >control. I have the viewpoint and viewdirection as 3d vectors in object
- >space. I need to rotate the viewdirection vector, for example, "down" wrt to
- >the current viewdirection. I've figured out the vector for the axis
- >(say, (1,3,2) ) of rotation but I don't know the rotation matrix
- >for rotation about that non-basic axis. I'd rather not have to convert
- >to eye-coordinate space.
- >
- >I vaguely remember some kind of matrix formula for which the familiar x-,
- >y-, and z-rotation matrices were but special cases. Does such a
- >formula exist? Something about "Euler angles"...
- >
- >---Charlie Ledogar
- >ledogar@eniac.seas.upenn.edu
-
- This can be done using quaternions.
-
- A rotation of magnitude theta around an arbitrary axis (x, y, z)
- corresponds to a unit quaternion q=(q0, q1, q2, q3), where
-
- q0 = cos (theta/2),
- q1 = x * sin (theta/2),
- q2 = y * sin (theta/2),
- q3 = z * sin (theta/2),
-
- assuming (x, y, z) is a unit vector itself. A quaternion q of
- the above form corresponds to the following premultiplied rotation matrix:
-
- | q0^2+q1^2-q2^2-q3^2 2(q3q0+q1q2) 2(q1q3-q0q2) |
- | 2(q1q2-q0q3) q0^2-q1^2+q2^2-q3^2 2(q1q0+q3q2) |
- | 2(q1q3+q0q2) 2(q2q3-q0q1) q0^2-q1^2-q2^2+q3^2) |
-
- Jiandong Liang
- leung@cs.ualberta.ca
-
-
-