[Tuxracer-checkins] CVS: tuxracer/src alglib.c,1.5,1.6 alglib.h,1.4,1.5
Status: Beta
Brought to you by:
jfpatry
From: Jasmin P. <jf...@us...> - 2000-08-31 15:24:43
|
Update of /cvsroot/tuxracer/tuxracer/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv28048 Modified Files: alglib.c alglib.h Log Message: Added routine to find intersection point of three planes. Index: alglib.c =================================================================== RCS file: /cvsroot/tuxracer/tuxracer/src/alglib.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** alglib.c 2000/08/26 23:28:41 1.5 --- alglib.c 2000/08/31 15:24:39 1.6 *************** *** 24,27 **** --- 24,28 ---- #include "tuxracer.h" #include "alglib.h" + #include "gauss.h" vector_t make_vector( scalar_t x, scalar_t y, scalar_t z ) *************** *** 222,225 **** --- 223,261 ---- return tmp; + } + + bool_t intersect_planes( plane_t s1, plane_t s2, plane_t s3, point_t *p ) + { + double A[3][4]; + double x[3]; + scalar_t retval; + + A[0][0] = s1.nml.x; + A[0][1] = s1.nml.y; + A[0][2] = s1.nml.z; + A[0][3] = -s1.d; + + A[1][0] = s2.nml.x; + A[1][1] = s2.nml.y; + A[1][2] = s2.nml.z; + A[1][3] = -s2.d; + + A[2][0] = s3.nml.x; + A[2][1] = s3.nml.y; + A[2][2] = s3.nml.z; + A[2][3] = -s3.d; + + retval = gauss( (double*) A, 3, x); + + if ( retval != 0 ) { + /* Matrix is singular */ + return False; + } else { + /* Solution found */ + p->x = x[0]; + p->y = x[1]; + p->z = x[2]; + return True; + } } Index: alglib.h =================================================================== RCS file: /cvsroot/tuxracer/tuxracer/src/alglib.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** alglib.h 2000/04/02 21:39:59 1.4 --- alglib.h 2000/08/31 15:24:39 1.5 *************** *** 62,65 **** --- 62,66 ---- /* planes */ plane_t make_plane( scalar_t nx, scalar_t ny, scalar_t nz, scalar_t d ); + bool_t intersect_planes( plane_t s1, plane_t s2, plane_t s3, point_t *p ); /* matrices */ |