home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / lib / geometry / transform3 / tm3concat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-11  |  3.1 KB  |  110 lines

  1. /* Copyright (c) 1992 The Geometry Center; University of Minnesota
  2.    1300 South Second Street;  Minneapolis, MN  55454, USA;
  3.    
  4. This file is part of geomview/OOGL. geomview/OOGL is free software;
  5. you can redistribute it and/or modify it only under the terms given in
  6. the file COPYING, which you should have received along with this file.
  7. This and other related software may be obtained via anonymous ftp from
  8. geom.umn.edu; email: software@geom.umn.edu. */
  9.  
  10. /* Authors: Charlie Gunn, Pat Hanrahan, Stuart Levy, Tamara Munzner, Mark Phillips */
  11.  
  12. #include <stdio.h>
  13. #include "transform3.h"
  14.  
  15. /************************************************************************
  16.  * NOTE: we're taking out PostConcat and PreConcat.  They're being left    *
  17.  * here for a short while longer as a memorial.                *
  18.  ************************************************************************/
  19.  
  20. /*-----------------------------------------------------------------------
  21.  * Function:    Tm3PostConcat
  22.  * Description:    concatenate one transform to another on the right
  23.  * Args:    Ta: left transform    (INPUT & OUTPUT)
  24.  *        Tb: right transform    (INPUT)
  25.  * Returns:    nothing
  26.  * Author:    hanrahan, mbp
  27.  * Date:    Thu Aug  8 13:31:35 1991
  28.  * Notes:    Sets Ta to Ta * Tb.
  29.  */
  30. void
  31. Tm3PostConcat( Ta, Tb )
  32.      Transform3 Ta, Tb;
  33. {
  34.   fprintf(stderr, "WARNING: obsolete function Tm3PostConcat called.  Use\n\
  35. Tm3Concat instead.\n");
  36.   Tm3Concat( Ta, Tb, Ta );
  37. }
  38.  
  39. /*-----------------------------------------------------------------------
  40.  * Function:    Tm3PreConcat
  41.  * Description:    concatenate one transform to another on the left
  42.  * Args:    Ta: left transform    (INPUT)
  43.  *        Tb: right transform    (INPUT & OUTPUT)
  44.  * Returns:    nothing
  45.  * Author:    hanrahan, mbp
  46.  * Date:    Thu Aug  8 13:31:35 1991
  47.  * Notes:    Sets Tb to Ta * Tb.
  48.  */
  49. void
  50. Tm3PreConcat( Ta, Tb )
  51.     Transform3 Ta, Tb;
  52. {
  53.   fprintf(stderr, "WARNING: obsolete function Tm3PreConcat called.  Use\n\
  54. Tm3Concat instead.\n");
  55.     Tm3Concat( Ta, Tb, Tb );
  56. }
  57.  
  58.  
  59.  
  60.  
  61. /*-----------------------------------------------------------------------
  62.  * Function:    Tm3Concat
  63.  * Description:    concatenate two transforms
  64.  * Args:    Ta: left factor  (INPUT)
  65.  *        Tb: right factor (INPUT)
  66.  *        Tprod: product (OUTPUT)
  67.  * Returns:    nothing
  68.  * Author:    hanrahan, mbp
  69.  * Date:    Thu Aug  8 13:15:08 1991
  70.  * Notes:    Passing the same transform for either factor and the
  71.  *        product is allowed.
  72.  */
  73. void
  74. Tm3Concat( Ta, Tb, Tprod )
  75.   register Transform3 Ta, Tb, Tprod;
  76. {
  77.   register int i;
  78.   
  79. #define MAKEPRODUCT(T)                \
  80.     for( i=0; i<4; i++ ) {            \
  81.     T[i][0] = Ta[i][0]*Tb[0][0] +        \
  82.           Ta[i][1]*Tb[1][0] +        \
  83.           Ta[i][2]*Tb[2][0] +        \
  84.           Ta[i][3]*Tb[3][0];        \
  85.     T[i][1] = Ta[i][0]*Tb[0][1] +        \
  86.           Ta[i][1]*Tb[1][1] +        \
  87.           Ta[i][2]*Tb[2][1] +        \
  88.           Ta[i][3]*Tb[3][1];        \
  89.     T[i][2] = Ta[i][0]*Tb[0][2] +        \
  90.           Ta[i][1]*Tb[1][2] +        \
  91.           Ta[i][2]*Tb[2][2] +        \
  92.           Ta[i][3]*Tb[3][2];        \
  93.     T[i][3] = Ta[i][0]*Tb[0][3] +        \
  94.           Ta[i][1]*Tb[1][3] +        \
  95.           Ta[i][2]*Tb[2][3] +        \
  96.           Ta[i][3]*Tb[3][3];        \
  97.       }
  98.  
  99.   if( Ta == Tprod || Tb == Tprod ) {
  100.     Transform3 T;
  101.     MAKEPRODUCT(T);
  102.     memcpy( Tprod, T, sizeof(Transform3) );
  103.   }
  104.   else {
  105.     MAKEPRODUCT(Tprod);
  106.   }
  107.  
  108. #undef MAKEPRODUCT
  109. }
  110.