Xref: utzoo rec.games.programmer:3355 comp.os.msdos.programmer:4526 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!viusys!uxui!unislc!ttobler From: ttobler@unislc.uucp (Trent Tobler) Newsgroups: rec.games.programmer,comp.os.msdos.programmer Subject: Re: 3D Rotation Message-ID: <1991Apr8.224148.18412@unislc.uucp> Date: 8 Apr 91 22:41:48 GMT References: <1991Apr05.224711.12750@lynx.CS.ORST.EDU> Organization: unisys Lines: 79 From article <1991Apr05.224711.12750@lynx.CS.ORST.EDU>, by murrayk@prism.CS.ORST.EDU: > > [Article on problem with 3D rotations] Perhaps, if instead of thinking in terms of rotation, you thought in terms of A) tranformation, or B) point of view. Both of these are two methods I know of to do "3 dimension rotation". In the first method, primitive matricies are multiplied together to product a composite 'transformation' matrix. Then to transform your coordinates, you would multiply a vector of your point with the matrix. An example of a matrix transform is... / 1 0 0 0 \ / 1 0 0 0 \ | 0 cos(t) sin(t) 0 | X | 0 1 0 0 | = Tranformation | 0 -sin(t) cos(t) 0 | | 0 0 1 0 | Matrix \ 0 0 0 1 / \ -2 1 3 1 / rotate by t radians move origin to ( 2, -1, -3) in the y-z plane Then to get the new location of point [x y z], do / \ [x y z 1] X | Transformation | = [x' y' z' 1] | Matrix | \ / and then plot perhaps (x', y') to the screen. I suggest you read some books on matricies (linear algebra), and consult more books on three-dimensional graphics. The other method involves using a 'camera' or an 'eye' similar to that used by ray tracers. This involves taking a point in the space, E = [ex ey ez] as the camera, having a window (I usually specify this as two vectors X, and Y, and W - all vectors). Then to convert a point from three dimensions to two dimensions, a line is constructed between the camera and the point, P = [px py pz], finding the intersection on the window, ie. solve t(P - E) + E = x'X + y'Y + W for (x', y'), and then simply use the x' and y' as the coordinates on your window. (note: t is also solved for to determine if the point is virtual, ie,. behind the camera) If you plan on using this method, you should read on vector algebra (which should also be covered in a book on linear algebra), and look into books on ray-tracing, as well as general three dimensional graphic books. The advantages of each method are: Transformations are simple to calculate, and can do more than just 'what we would really see if this existed' type pictures. It can rotate, shift, change size, and skew objects in three dimensions. Point of view leads to an easy way of generating relistic pictures, and perspective is handled automatically. It can move around and throught the objects with ease. Problems with the methods are: Transformations are quite complex, and determining a specific reference can sometime be very difficult. It is more difficult to do the things that point of view handles easily. Also, calculating the transformation matrix can be very computationally intense. Point of view has problems with virtual points when drawing lines from virtual point to visible point (virtual points are those that are behind the camera). It also lacks the ease that transformations have when doing skewed and distorted images. My suggestion: explore both of these methods. It is possible to combine the two to get more power (at cost of computation) at changing your image. -- Trent Tobler - ttobler@csulx.weber.edu