[Plib-cvs] plib/src/puAux puAuxCompass.cxx,1.2,1.3
Brought to you by:
sjbaker
From: Steve B. <sj...@us...> - 2004-03-18 19:24:22
|
Update of /cvsroot/plib/plib/src/puAux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13664/plib/src/puAux Modified Files: puAuxCompass.cxx Log Message: Moved some math out of puAux and into SG. Index: puAuxCompass.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/puAux/puAuxCompass.cxx,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- puAuxCompass.cxx 28 Feb 2004 22:35:03 -0000 1.2 +++ puAuxCompass.cxx 18 Mar 2004 19:14:43 -0000 1.3 @@ -33,54 +33,6 @@ UL_RTTI_DEF1(puaCompass,puObject) - -/* Function to rotate a vector through a given quaternion using the formula - * R = Q r Q-1 -- this gives the components of a ROTATED vector in a STATIONARY - * coordinate system. We assume that Q is a unit quaternion. - */ -void sgRotateVecQuat ( sgVec3 vec, sgQuat q ) -{ - sgVec3 rot ; [...77 lines suppressed...] - sgNegateVec3 ( t1_t2_t2_minus_t1 ) ; - sgAddScaledVec3 ( t2_minus_t1_t2_t1, line2.direction_vector, line.direction_vector, -t1_dot_t2 ) ; - - sgFloat u = sgScalarProductVec3 ( r1_minus_r2, t1_t2_t2_minus_t1 ) / ( 1.0f - t1_dot_t2 * t1_dot_t2 ) ; - sgFloat v = sgScalarProductVec3 ( r1_minus_r2, t2_minus_t1_t2_t1 ) / ( 1.0f - t1_dot_t2 * t1_dot_t2 ) ; - - /* Since line 2 is a line segment, we limit "v" to between 0 and the distance between the points. */ - sgFloat length = sgDistanceVec3 ( seg.a, seg.b ) ; - if ( v < 0.0 ) v = 0.0 ; - if ( v > length ) v = length ; - - sgVec3 point1, point2 ; - sgAddScaledVec3 ( point1, line.point_on_line, line.direction_vector, u ) ; - sgAddScaledVec3 ( point2, line2.point_on_line, line2.direction_vector, v ) ; - return sgDistanceSquaredVec3 ( point1, point2 ) ; -} - void puaCompass::doHit ( int button, int updown, int x, int y ) { |