ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/mat4.c
(Generate patch)

Comparing ray/src/common/mat4.c (file contents):
Revision 1.2 by greg, Tue Oct 24 14:01:17 1989 UTC vs.
Revision 2.1 by greg, Tue Nov 12 16:54:53 1991 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1990 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10   *     10/19/85
11   */
12  
13 + #include  "mat4.h"
14  
15 < static double  m4tmp[4][4];             /* for efficiency */
15 > MAT4  m4ident = MAT4IDENT;
16  
17 < #define  copymat4(m4a,m4b)      bcopy((char *)m4b,(char *)m4a,sizeof(m4tmp))
17 > static MAT4  m4tmp;             /* for efficiency */
18  
19  
19 setident4(m4)
20 double  m4[4][4];
21 {
22        static double  ident[4][4] = {
23                1.,0.,0.,0.,
24                0.,1.,0.,0.,
25                0.,0.,1.,0.,
26                0.,0.,0.,1.,
27        };
28        copymat4(m4, ident);
29 }
30
31
20   multmat4(m4a, m4b, m4c)         /* multiply m4b X m4c and put into m4a */
21 < double  m4a[4][4];
22 < register double  m4b[4][4], m4c[4][4];
21 > MAT4  m4a;
22 > register MAT4  m4b, m4c;
23   {
24          register int  i, j;
25          
# Line 47 | Line 35 | register double  m4b[4][4], m4c[4][4];
35  
36  
37   multv3(v3a, v3b, m4)    /* transform vector v3b by m4 and put into v3a */
38 < double  v3a[3];
39 < register double  v3b[3];
40 < register double  m4[4][4];
38 > FVECT  v3a;
39 > register FVECT  v3b;
40 > register MAT4  m4;
41   {
42 <        register int  i;
42 >        m4tmp[0][0] = v3b[0]*m4[0][0] + v3b[1]*m4[1][0] + v3b[2]*m4[2][0];
43 >        m4tmp[0][1] = v3b[0]*m4[0][1] + v3b[1]*m4[1][1] + v3b[2]*m4[2][1];
44 >        m4tmp[0][2] = v3b[0]*m4[0][2] + v3b[1]*m4[1][2] + v3b[2]*m4[2][2];
45          
56        for (i = 0; i < 3; i++)
57                m4tmp[0][i] = v3b[0]*m4[0][i] +
58                              v3b[1]*m4[1][i] +
59                              v3b[2]*m4[2][i];
60        
46          v3a[0] = m4tmp[0][0];
47          v3a[1] = m4tmp[0][1];
48          v3a[2] = m4tmp[0][2];
# Line 65 | Line 50 | register double  m4[4][4];
50  
51  
52   multp3(p3a, p3b, m4)            /* transform p3b by m4 and put into p3a */
53 < register double  p3a[3];
54 < double  p3b[3];
55 < register double  m4[4][4];
53 > register FVECT  p3a;
54 > FVECT  p3b;
55 > register MAT4  m4;
56   {
57          multv3(p3a, p3b, m4);   /* transform as vector */
58          p3a[0] += m4[3][0];     /* translate */
# Line 76 | Line 61 | register double  m4[4][4];
61   }
62  
63  
79 #ifdef  INVMAT
64   /*
65   * invmat - computes the inverse of mat into inverse.  Returns 1
66   * if there exists an inverse, 0 otherwise.  It uses Gaussian Elimination
# Line 84 | Line 68 | register double  m4[4][4];
68   */
69  
70   invmat(inverse,mat)
71 < double mat[4][4],inverse[4][4];
71 > MAT4  mat, inverse;
72   {
73   #define SWAP(a,b,t) (t=a,a=b,b=t)
74   #define ABS(x) (x>=0?x:-(x))
# Line 93 | Line 77 | double mat[4][4],inverse[4][4];
77          register double temp;
78  
79          copymat4(m4tmp, mat);
80 <        setident(inverse);
80 >        setident4(inverse);
81  
82          for(i = 0; i < 4; i++) {
83                  /* Look for row with largest pivot and swap rows */
# Line 131 | Line 115 | double mat[4][4],inverse[4][4];
115   #undef ABS
116   #undef SWAP
117   }
134 #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines