📄 node82.html
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.2 Final//FR"><!-- Converted with LaTeX2HTML 95.1 (Fri Jan 20 1995) --><!-- by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds --><!-- Modified Simulog 03/97 --><HTML><HEAD><TITLE>4.4 The transformations</TITLE><LINK REL=STYLESHEET TYPE="text/css" HREF="./Modulef.css" TITLE="Modulef CSS"><meta name="description" value="4.4 The transformations"><meta name="keywords" value="Guide6"><meta name="resource-type" value="document"><meta name="distribution" value="global"></HEAD><BODY BGCOLOR="#FFFFFF"><P> <IMG SRC="../icons/smallmod.gif" WIDTH=211 HEIGHT=50 ALIGN=BOTTOM ALT="Modulef"><A NAME=tex2html1437 HREF="node81.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/previous_motif.gif" ALT="previous"></A><A NAME=tex2html1443 HREF="node78.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/up_motif.gif" ALT="up"></A><A NAME=tex2html1445 HREF="node83.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/next_motif.gif" ALT="next"></A><A NAME=tex2html1447 HREF="node2.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/contents_motif.gif" ALT="contents"></A><A HREF="../Guide6-18/node82.html"><IMG BORDER=0 SRC="../icons/zoom18.gif" ALIGN=BOTTOM ALT="[BIG]"></A><A HREF="../Guide6-14/node82.html"><IMG BORDER=0 SRC="../icons/zoom14.gif" ALIGN=BOTTOM ALT="[Normal]"></A><A HREF="../Guide6-10/node82.html"><IMG BORDER=0 SRC="../icons/zoom10.gif" ALIGN=BOTTOM ALT="[small]"></A><BR><B> Next: </B> <A NAME=tex2html1446 HREF="node83.html">4.5 3D graphics instructions</A><B>Up: </B> <A NAME=tex2html1444 HREF="node78.html">4 Creating a 3D image</A><B> Prev: </B> <A NAME=tex2html1438 HREF="node81.html">4.3 3D transformations</A><B><A HREF="node2.html" >Contents</A></B><HR SIZE=3 WIDTH="75%"><H1><A NAME=SECTION05440000000000000000>4.4 The transformations</A></H1><P><P><P>As seen before, it corresponds to first of all positioning the observer with respect to the object.In case of stacking PUSHes and PULLs, it corresponds to positioning an object with respect to another.<P>Let us take an example: Suppose that we construct the following object composed of two separate objects: PIECE A, a cube with center of gravity 'O' and PIECE B, a cylinder glued onto one of its faces. We can proceed with its description in two different ways:<P><DL COMPACT><DT>Method I:<DD> We describe the cube and cylinder directly at their respective positions by entering the coordinates of the points in the general coordinate system.<P><DT>Method II:<DD> We first describe the cube in its own coordinate system. Then we describe the cylinder in its own coordinate system. We then perform transformations on the coordinate system of the cylinder to position it in the coordinate system of the cube.<P> </DL><P>However, in both cases, we must first position the observer with respect to the object.<P>Let us adopt the following vocabulary:<P><DL COMPACT><DT>Calling object:<DD> initial object (the cube) <DT>Called object:<DD> object undergoing the transformations (the cylinder)<P> </DL><P> A very simple manner to position the observer in the initial space is to use the following subroutine:<P><PRE> SUBROUTINE NRMLST(XO, YO, ZO, XR, YR, ZR, IVERTI) REAL XO, YO, ZO, XR, YR, ZR INTEGER IVERTI</PRE>where:<P> (XO, YO, ZO) is the<A NAME=3144> </A> position of the observer in the initial coordinate system;<P> (XR, YR, ZR) represent the coordinates of the point viewed in the same coordinate system;<P> IVERTI is the vertical of the initial coordinate system, such that:<P><DL COMPACT><DT>.<DD> IVERTI = 1 : OX vertical <DT>.<DD> IVERTI = 2 : OY vertical <DT>.<DD> IVERTI = 3 : OZ vertical<P> </DL><P><P><P>We can thus associate a local coordinate system with the observer so that he/she is positioned atits origin, looking in the negative Z direction. This is the normalized position of which we spoke earlier.<P>Subroutine NRMLST is generally used in conjunction with "PRSPCT".<P><P><A NAME=3568> </A><IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img131.gif"><BR><STRONG>Figure 4.4:</STRONG> <i> Coordinates corresponding to the observer</i><A NAME=3564iCoordinatescorrespondingtotheobserveri3564> </A><BR><P><P>The various transformations that can be applied to the called objects are listed below:<P><UL><LI><P><PRE> SUBROUTINE TRSL(A, B, C) REAL A, B, C</PRE><P>defines a<A NAME=3151> </A> translation of the called object by a vector (A, B, C) with respect to the calling object.??<P><LI><P><PRE> SUBROUTINE ROT(I, ALPHA) INTEGER I REAL ALPHA</PRE><P>defines a<A NAME=3152> </A> rotation of the called object of an angle ALPHA radians around an axis I, where the positive direction is the trigonometric direction.The axis numbers are given by:<DL COMPACT><DT>.<DD> 1 : axis OX <DT>.<DD> 2 : axis OY <DT>.<DD> 3 : axis OZ<P> </DL><P><LI><P><PRE> SUBROUTINE ROTAXE(PX, PY, PZ, VX, VY, VZ, THETA) REAL PX, PY, PZ, VX, VY, VZ, THETA</PRE><P>defines a<A NAME=3155> </A> rotation of the called object of an angle THETA radians around the axis defined by thevector with origin (PX, PY, PZ) and components (VX, VY, VZ).<P><LI><P><PRE> SUBROUTINE SYMTRI(I, J) INTEGER I, J</PRE><P>defines a<A NAME=3156> </A> symmetry of the called object:<P><DL COMPACT><DT>.<DD> I = 1 Symmetry with respect to the origin;<P> <DT>.<DD> I = 2 Symmetry with respect to a plane:<UL><LI> J = 1 Plane XOY <LI> J = 2 Plane YOZ <LI> J = 3 Plane ZOX<P></UL> <DT>.<DD> I = 3 Symmetry with respect to an axis:<UL><LI> J = 1 Axis OX <LI> J = 2 Axis OY <LI> J = 3 Axis OZ</UL> </DL><P><LI><P><PRE> SUBROUTINE SCALE(A, B, C) REAL A, B, C</PRE><P> defines a<A NAME=3163> </A> scale change of the called object along axis OX by a factor A, OY by a factor B and OZ by a factor C.<P><LI><P><PRE> SUBROUTINE SHEAR(A, B, C) REAL A, B, C</PRE><P>defines a<A NAME=3164> </A> shearing, i.e. the following transformation:<P><PRE> X' = X + B*Y + C*Z Y' = A*X + Y + C*Z Z' = A*X + B*Y + Z</PRE><P><LI><P><PRE> SUBROUTINE POS3D(P1, P2, P3, Q1, Q2, Q3) REAL P1(3), P2(3), P3(3), Q1(3), Q2(3), Q3(3)</PRE><P>where P1, P2 and P3 are the three points in the called object's space<A NAME=3165> </A>, and Q1, Q2 and Q3 are three points in the calling object's space (thus, the above two sets of three pointseach define a plane in the 3d space).<P>This transformation enables the user to superpose two planes (and thus position the called object with respect to the calling object) in the following manner:<P><UL><LI> P1 becomes Q1 <LI> P2 is positioned on line (Q1,Q2) <LI> P3 is positioned in plane (Q1,Q2,Q3) </UL>The normals to the planes (Q1,Q2,Q3) and (P1,P2,P3) are collinear and in the same direction, afterrepositioning.<P><P><A NAME=3578> </A><IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img132.gif"><BR><STRONG>Figure 4.5:</STRONG> <i> Transformation contained by calling subroutine POS3D</i><A NAME=3574iTransformationcontainedbycallingsubroutinePOS3Di3574> </A><BR><P><P>Another subroutine exists which enables the user to define his own transformation himself by inputting his own transformation matrix. The latter is a 4<IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img133.gif">4 matrix whose structure is described in the chapterdealing with internal subroutines.<P><LI><P><PRE> SUBROUTINE TRANSF(MAT) REAL MAT(4, 4)</PRE><P>defines a<A NAME=3171> </A> transformation via matrix MAT in homogeneous coordinates (see Chapter <A HREF="node92.html#chap_intern">7</A>dealing with internal subroutines for the matrix structure).</UL><P><P><P><HR SIZE=3 WIDTH="75%"><IMG SRC="../icons/smallmod.gif" WIDTH=211 HEIGHT=50 ALIGN=BOTTOM ALT="Modulef"><A NAME=tex2html1437 HREF="node81.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/previous_motif.gif" ALT="previous"></A><A NAME=tex2html1443 HREF="node78.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/up_motif.gif" ALT="up"></A><A NAME=tex2html1445 HREF="node83.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/next_motif.gif" ALT="next"></A><A NAME=tex2html1447 HREF="node2.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/contents_motif.gif" ALT="contents"></A><A HREF="../Guide6-18/node82.html"><IMG BORDER=0 SRC="../icons/zoom18.gif" ALIGN=BOTTOM ALT="[BIG]"></A><A HREF="../Guide6-14/node82.html"><IMG BORDER=0 SRC="../icons/zoom14.gif" ALIGN=BOTTOM ALT="[Normal]"></A><A HREF="../Guide6-10/node82.html"><IMG BORDER=0 SRC="../icons/zoom10.gif" ALIGN=BOTTOM ALT="[small]"></A><BR><B> Next: </B> <A NAME=tex2html1446 HREF="node83.html">4.5 3D graphics instructions</A><B>Up: </B> <A NAME=tex2html1444 HREF="node78.html">4 Creating a 3D image</A><B> Prev: </B> <A NAME=tex2html1438 HREF="node81.html">4.3 3D transformations</A><B><A HREF="node2.html" >Contents</A></B><BR> <HR><P><ADDRESS></ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -