1 /* Copyright (C) 1992-1998 The Geometry Center
2 * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips
3 *
4 * This file is part of Geomview.
5 *
6 * Geomview is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * Geomview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Geomview; see the file COPYING. If not, write
18 * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
19 * USA, or visit http://www.gnu.org.
20 */
21
22 #if HAVE_CONFIG_H
23 # include "config.h"
24 #endif
25
26 #if 0
27 static char copyright[] = "Copyright (C) 1992-1998 The Geometry Center\n\
28 Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips";
29 #endif
30
31
32 /* Authors: Charlie Gunn, Pat Hanrahan, Stuart Levy, Tamara Munzner, Mark Phillips */
33
34 #include <stdio.h>
35 #include <string.h>
36 #include "transform3.h"
37
38 /************************************************************************
39 * NOTE: we're taking out PostConcat and PreConcat. They're being left *
40 * here for a short while longer as a memorial. *
41 ************************************************************************/
42
43 /*-----------------------------------------------------------------------
44 * Function: Tm3PostConcat
45 * Description: concatenate one transform to another on the right
46 * Args: Ta: left transform (INPUT & OUTPUT)
47 * Tb: right transform (INPUT)
48 * Returns: nothing
49 * Author: hanrahan, mbp
50 * Date: Thu Aug 8 13:31:35 1991
51 * Notes: Sets Ta to Ta * Tb.
52 */
53 void
Tm3PostConcat(Ta,Tb)54 Tm3PostConcat( Ta, Tb )
55 Transform3 Ta, Tb;
56 {
57 fprintf(stderr, "WARNING: obsolete function Tm3PostConcat called. Use\n\
58 Tm3Concat instead.\n");
59 Tm3Concat( Ta, Tb, Ta );
60 }
61
62 /*-----------------------------------------------------------------------
63 * Function: Tm3PreConcat
64 * Description: concatenate one transform to another on the left
65 * Args: Ta: left transform (INPUT)
66 * Tb: right transform (INPUT & OUTPUT)
67 * Returns: nothing
68 * Author: hanrahan, mbp
69 * Date: Thu Aug 8 13:31:35 1991
70 * Notes: Sets Tb to Ta * Tb.
71 */
72 void
Tm3PreConcat(Ta,Tb)73 Tm3PreConcat( Ta, Tb )
74 Transform3 Ta, Tb;
75 {
76 fprintf(stderr, "WARNING: obsolete function Tm3PreConcat called. Use\n\
77 Tm3Concat instead.\n");
78 Tm3Concat( Ta, Tb, Tb );
79 }
80
81
82
83
84 /*-----------------------------------------------------------------------
85 * Function: Tm3Concat
86 * Description: concatenate two transforms
87 * Args: Ta: left factor (INPUT)
88 * Tb: right factor (INPUT)
89 * Tprod: product (OUTPUT)
90 * Returns: nothing
91 * Author: hanrahan, mbp
92 * Date: Thu Aug 8 13:15:08 1991
93 * Notes: Passing the same transform for either factor and the
94 * product is allowed.
95 */
96 void
Tm3Concat(Ta,Tb,Tprod)97 Tm3Concat( Ta, Tb, Tprod )
98 Transform3 Ta, Tb, Tprod;
99 {
100 int i;
101
102 #define MAKEPRODUCT(T) \
103 for( i=0; i<4; i++ ) { \
104 T[i][0] = Ta[i][0]*Tb[0][0] + \
105 Ta[i][1]*Tb[1][0] + \
106 Ta[i][2]*Tb[2][0] + \
107 Ta[i][3]*Tb[3][0]; \
108 T[i][1] = Ta[i][0]*Tb[0][1] + \
109 Ta[i][1]*Tb[1][1] + \
110 Ta[i][2]*Tb[2][1] + \
111 Ta[i][3]*Tb[3][1]; \
112 T[i][2] = Ta[i][0]*Tb[0][2] + \
113 Ta[i][1]*Tb[1][2] + \
114 Ta[i][2]*Tb[2][2] + \
115 Ta[i][3]*Tb[3][2]; \
116 T[i][3] = Ta[i][0]*Tb[0][3] + \
117 Ta[i][1]*Tb[1][3] + \
118 Ta[i][2]*Tb[2][3] + \
119 Ta[i][3]*Tb[3][3]; \
120 }
121
122 if( Ta == Tprod || Tb == Tprod ) {
123 Transform3 T;
124 MAKEPRODUCT(T);
125 memcpy( Tprod, T, sizeof(Transform3) );
126 }
127 else {
128 MAKEPRODUCT(Tprod);
129 }
130
131 #undef MAKEPRODUCT
132 }
133