1 |
– |
/* Copyright (c) 1994 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* invmat4 - computes the inverse of mat into inverse. Returns 1 |
6 |
|
* if there exists an inverse, 0 otherwise. It uses Gaussian Elimination |
7 |
|
* method. |
8 |
|
*/ |
9 |
|
|
10 |
+ |
#include "copyright.h" |
11 |
+ |
|
12 |
|
#include "mat4.h" |
13 |
|
|
14 |
|
|
17 |
|
#define SWAP(a,b,t) (t=a,a=b,b=t) |
18 |
|
|
19 |
|
|
20 |
< |
invmat4(inverse,mat) |
20 |
> |
int |
21 |
> |
invmat4(inverse, mat) |
22 |
|
MAT4 inverse, mat; |
23 |
|
{ |
24 |
|
MAT4 m4tmp; |
27 |
|
|
28 |
|
copymat4(m4tmp, mat); |
29 |
|
/* set inverse to identity */ |
30 |
< |
for (i = 0; i < 4; i++) |
31 |
< |
for (j = 0; j < 4; j++) |
32 |
< |
inverse[i][j] = i==j ? 1.0 : 0.0; |
30 |
> |
setident4(inverse); |
31 |
|
|
32 |
|
for(i = 0; i < 4; i++) { |
33 |
|
/* Look for row with largest pivot and swap rows */ |