📄 node98.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>7.6 Matrix and vector manipulations</TITLE><LINK REL=STYLESHEET TYPE="text/css" HREF="./Modulef.css" TITLE="Modulef CSS"><meta name="description" value="7.6 Matrix and vector manipulations"><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=tex2html1621 HREF="node97.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/previous_motif.gif" ALT="previous"></A><A NAME=tex2html1627 HREF="node92.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/up_motif.gif" ALT="up"></A><A NAME=tex2html1629 HREF="node99.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/next_motif.gif" ALT="next"></A><A NAME=tex2html1631 HREF="node2.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/contents_motif.gif" ALT="contents"></A><A HREF="../Guide6-18/node98.html"><IMG BORDER=0 SRC="../icons/zoom18.gif" ALIGN=BOTTOM ALT="[BIG]"></A><A HREF="../Guide6-14/node98.html"><IMG BORDER=0 SRC="../icons/zoom14.gif" ALIGN=BOTTOM ALT="[Normal]"></A><A HREF="../Guide6-10/node98.html"><IMG BORDER=0 SRC="../icons/zoom10.gif" ALIGN=BOTTOM ALT="[small]"></A><BR><B> Next: </B> <A NAME=tex2html1630 HREF="node99.html">7.7 Sorting and dichotomy</A><B>Up: </B> <A NAME=tex2html1628 HREF="node92.html">7 Internal programs</A><B> Prev: </B> <A NAME=tex2html1622 HREF="node97.html">7.5 Conversions</A><B><A HREF="node2.html" >Contents</A></B><HR SIZE=3 WIDTH="75%"><H1><A NAME=SECTION05760000000000000000>7.6 Matrix and vector manipulations</A></H1><P><P><P><UL><PRE> SUBROUTINE NRMVCT(V1, V) REAL V1(3), V(3)</PRE><P> Normalization of<A NAME=3412> </A> vector V1: <IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img142.gif"> <BR><P><LI><P><PRE> SUBROUTINE PRDVCT(V1, V2, V) REAL V1(3), V2(3), V(3)</PRE><P>Vector product<A NAME=3415> </A>: <b>V=V1*V2</b><P> <LI><P><PRE> REAL FUNCTION PRDSCL(V1, V2) REAL V1(3), V2(3)</PRE><P>Scalar product<A NAME=3416> </A>: <b> PRDSCL=V1.V2 </b><P><LI><P><PRE> REAL FUNCTION PRDMXT(V1, V2, V3) REAL V1(3), V2(3), V3(3) EXTERNAL PRDSCL REAL PRDSCL</PRE><P>Mixed product<A NAME=3417> </A>: <b> PRDMXT=V1.(V2*V3) </b><P><LI><P><PRE> SUBROUTINE NORMAL(CC) REAL CC(4)</PRE><P>converts<A NAME=3418> </A> CC(1:4), in homogeneous coordinates, into normal coordinates. (i.e. such that CC(4) = 1.).<P></UL><P>Calling subroutines which perform transformations in the three-dimensional space, initiates matrix computations corresponding to the linear application associated with the transformation.<P>Other subroutines perform clipping computations (see masks and windows).Generally, the user does not deal with these subroutines. However, for certaincomputations (not necessarily graphical!), it is possible to employ these subroutines of practicalinterest, advantageously.<P><P><P>It is however necessary to stress certain notions.<P>The internal procedures in FORTRAN 3D manipulate a real type 4*4 matrix, henceforth called MAT(4, 4), consisting of a 3*3 sub-matrix, representing the rotation, and a vector corresponding to the last column, representing the translation.The lower right-hand corner of this matrix contains a 1. and the three first elements in the last line are zero, as shown below:<P><PRE> MAT(1:3, 1:3) ---> Rotation | R R R T | MAT(1:3, 4 ) ---> Translation | R R R T | | R R R T | MAT(4, 1:4) ---> | 0 0 0 1. |</PRE><P>Before performing any matrix operations, MAT must be initialized to a unit matrix. The transformation procedures are then called sequentially, each multiplying the matrix with a matrix corresponding to the transformation.At the end of the operations, the matrix contains the result of all the operations performed.<P><UL><LI><P><PRE> SUBROUTINE MATUNI(MAT) REAL MAT(4, 4)</PRE><P>returns a unit matrix in MAT<A NAME=3421> </A>. The call to this procedure is obligatory before using the subroutines mentioned below.<P><LI><P><PRE> SUBROUTINE LDMAT(MAT) REAL MAT(4, 4)</PRE><P>returns the matrix at the current stack level in MAT<A NAME=3422> </A>.This procedure can replace the preceding one if we wish to perform transformations relative to the current levelof operations in progress, instead of starting with the identity matrix.<P> <LI><P><PRE> SUBROUTINE PRDMAT(MAT1, MAT) REAL MAT1, MAT</PRE><P>returns the matrix product<A NAME=3423> </A>: <b> MAT = MAT1 * MAT </b> in MAT.<P><LI><P><PRE> SUBROUTINE TRSFO1(P, MAT) REAL P(4), MAT(4, 4)</PRE><P>returns the product<A NAME=3424> </A>: <b> P = P*MAT </b> in vector P.After transformation, P is in homogeneous coordinates.<P> <LI><P><PRE> SUBROUTINE INVMAT(MAT, MAT1) REAL MAT(4, 4), MAT1(4, 4)</PRE><P>returns the inverse of MAT<A NAME=3425> </A>, calculated by the Gauss-Jordan method(maximum pivot) in MAT1.<P><LI><P><PRE> SUBROUTINE TRSLL(A, B, C, MAT) REAL A, B, C, MAT(4, 4)</PRE><P>The translation is<A NAME=3426> </A> defined by: <b> X = X + A </b>, <b> Y = Y + B </b> et <b> Z = Z + C </b>. Calculate a translational matrix, M1, and then store the matrix product, <b> MAT = M1 * MAT </b>, in MAT.<P> <LI><P><PRE> SUBROUTINE ROTT(I, BETA, MAT) INTEGER I REAL BETA, MAT(4, 4)</PRE><P>calculates a rotational matrix<A NAME=3427> </A>, M1, of an angle BETA around an axis defined by the value in I: I=1 axis 0X, I=2 axis 0Y, or I=3 axis 0Z, and then returns the matrix product, <b> MAT = M1 * MAT </b>, in MAT.<P><LI><P><PRE> SUBROUTINE SCALEE(A, B, C, MAT) REAL A, B, C, MAT(4, 4)</PRE><P>Scale<A NAME=3428> </A>: <b> X = A * X </b>, <b> Y = B * Y </b> et <b> Z = C * Z</b>. Calculate a scaling matrix, M1, perform the matrix product, <b> MAT = M1 * MAT</b>, and return the result in MAT.<P><LI><P><PRE> SUBROUTINE SHEARR(A, B, C, MAT) REAL A, B, C, MAT(4, 4)</PRE><P>Define a <A NAME=3429> </A> shearing matrix, i.e. the following transformation: <BR> <IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img143.gif"> <BR> <IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img144.gif"> <BR> <IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img145.gif"> <BR><P> Then return the matrix product,<b> MAT = M1 * MAT</b>, in MAT.<P><LI><P><PRE> SUBROUTINE REPERR(XO, YO, ZO, XR, YR, ZR, IVERTI, MAT) REAL XO, YO, ZO, XR, YR, ZR, MAT(4, 4) INTEGER IVERTI</PRE>where: <BR> (XO, YO, ZO): the<A NAME=3430> </A> position of the observer in the object's coordinate system; <BR> (XR, YR, ZR): represents the coordinates of the point viewed in the same coordinate system; <BR> IVERTI: the vertical of the initial coordinate system:<P> IVERTI = 1 OX vertical<P> IVERTI = 2 OY vertical<P> IVERTI = 3 OZ vertical <BR><P>We can thus associate a local coordinate system with the observer such that he is positioned atthe origin, looking in the negative Z direction (normalized position).<P>This subroutine calculates this transformation's matrix, M1, and then returns the matrix product,<b> MAT = M1 * MAT</b>, in MAT.<P>See also subroutine NRMLST.<P><LI><P><PRE> SUBROUTINE ROTAXX(PX, PY, PZ, VX, VY, VZ, THETA, MAT) REAL PX, PY, PZ, VX, VY, VZ, THETA, MAT(4, 4)</PRE><P> calculates a rotational matrix<A NAME=3431> </A>, of an angle THETA radians around the axis defined by theorigin vector, (PX, PY, PZ), and component vector, (VX, VY, VZ), and then returnsthe matrix product, <b> MAT = M1 * MAT</b>, in MAT.<P>This corresponds to subroutine ROTAXE.<P><LI><P><PRE> SUBROUTINE SYMTRR(I, J, MAT) REAL MAT(4, 4) INTEGER I, J</PRE><P>This subroutine calculates a symmetry matrix, M1, and then returns the matrix product, <b> MAT = M1 * MAT</b>, in MAT, where:<P> I=1: symmetry w.r.t. the origin;<P> I=2: symmetry w.r.t. a plane: J=1: x0y, J=2: y0z, J=3: z0x;<P> I=3: symmetry w.r.t. an axis: J=1: 0x, J=2: 0y, J=3 0z. <BR><P>See subroutine<A NAME=3432> </A> SYMTRI.<P><LI><P><PRE> SUBROUTINE POS3DD(P1, P2, P3, Q1, Q2, Q3, MAT) REAL P1(3), P2(3), P3(3), Q1(3), Q2(3), Q3(3), MAT(4, 4)</PRE><P>calculates a transformation matrix, M1, and returns the matrix product, <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img146.gif">, in MAT.The matrix, MAT,<A NAME=3433> </A> positions the object defined by P1, P2, P3 at Q1, Q2, Q3.<P>See subroutine POS3D.<P></UL><P><P><P><HR SIZE=3 WIDTH="75%"><IMG SRC="../icons/smallmod.gif" WIDTH=211 HEIGHT=50 ALIGN=BOTTOM ALT="Modulef"><A NAME=tex2html1621 HREF="node97.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/previous_motif.gif" ALT="previous"></A><A NAME=tex2html1627 HREF="node92.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/up_motif.gif" ALT="up"></A><A NAME=tex2html1629 HREF="node99.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/next_motif.gif" ALT="next"></A><A NAME=tex2html1631 HREF="node2.html"><IMG BORDER=0 ALIGN=BOTTOM SRC="../icons/contents_motif.gif" ALT="contents"></A><A HREF="../Guide6-18/node98.html"><IMG BORDER=0 SRC="../icons/zoom18.gif" ALIGN=BOTTOM ALT="[BIG]"></A><A HREF="../Guide6-14/node98.html"><IMG BORDER=0 SRC="../icons/zoom14.gif" ALIGN=BOTTOM ALT="[Normal]"></A><A HREF="../Guide6-10/node98.html"><IMG BORDER=0 SRC="../icons/zoom10.gif" ALIGN=BOTTOM ALT="[small]"></A><BR><B> Next: </B> <A NAME=tex2html1630 HREF="node99.html">7.7 Sorting and dichotomy</A><B>Up: </B> <A NAME=tex2html1628 HREF="node92.html">7 Internal programs</A><B> Prev: </B> <A NAME=tex2html1622 HREF="node97.html">7.5 Conversions</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 + -