[Plib-cvs] plib/src/sg sg.cxx,1.33,1.34 sg.h,1.35,1.36
Brought to you by:
sjbaker
From: Steve B. <sj...@us...> - 2002-06-14 04:38:27
|
Update of /cvsroot/plib/plib/src/sg In directory usw-pr-cvs1:/tmp/cvs-serv26737/plib/src/sg Modified Files: sg.cxx sg.h Log Message: Moved SG's internal sin/cos/tan/acos/asin/atan routines into the header file so everyone can use them. Index: sg.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/sg/sg.cxx,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- sg.cxx 13 Jun 2002 05:53:02 -0000 1.33 +++ sg.cxx 14 Jun 2002 04:38:23 -0000 1.34 @@ -24,38 +24,6 @@ #include "sg.h" -/* Type-casted sqrt and sin/cos/tan/asin/acos/atan2 ARGUMENTS IN DEGREES */ - -inline SGDfloat sgdASin ( SGDfloat s ) - { return (SGDfloat) asin ( s ) * SGD_RADIANS_TO_DEGREES ; } -inline SGDfloat sgdACos ( SGDfloat s ) - { return (SGDfloat) acos ( s ) * SGD_RADIANS_TO_DEGREES ; } -inline SGDfloat sgdATan ( SGDfloat s ) - { return (SGDfloat) atan ( s ) * SGD_RADIANS_TO_DEGREES ; } -inline SGDfloat sgdATan2 ( SGDfloat y, SGDfloat x ) - { return (SGDfloat) atan2 ( y,x ) * SGD_RADIANS_TO_DEGREES ; } -inline SGDfloat sgdSin ( SGDfloat s ) - { return (SGDfloat) sin ( s * SGD_DEGREES_TO_RADIANS ) ; } -inline SGDfloat sgdCos ( SGDfloat s ) - { return (SGDfloat) cos ( s * SGD_DEGREES_TO_RADIANS ) ; } -inline SGDfloat sgdTan ( SGDfloat s ) - { return (SGDfloat) tan ( s * SGD_DEGREES_TO_RADIANS ) ; } - -inline SGfloat sgASin ( SGfloat s ) - { return (SGfloat) asin ( s ) * SG_RADIANS_TO_DEGREES ; } -inline SGfloat sgACos ( SGfloat s ) - { return (SGfloat) acos ( s ) * SG_RADIANS_TO_DEGREES ; } -inline SGfloat sgATan ( SGfloat s ) - { return (SGfloat) atan ( s ) * SG_RADIANS_TO_DEGREES ; } -inline SGfloat sgATan2 ( SGfloat y, SGfloat x ) - { return (SGfloat) atan2 ( y,x ) * SG_RADIANS_TO_DEGREES ; } -inline SGfloat sgSin ( SGfloat s ) - { return (SGfloat) sin ( s * SG_DEGREES_TO_RADIANS ) ; } -inline SGfloat sgCos ( SGfloat s ) - { return (SGfloat) cos ( s * SG_DEGREES_TO_RADIANS ) ; } -inline SGfloat sgTan ( SGfloat s ) - { return (SGfloat) tan ( s * SG_DEGREES_TO_RADIANS ) ; } - void sgVectorProductVec3 ( sgVec3 dst, const sgVec3 a, const sgVec3 b ) { dst[0] = a[1] * b[2] - a[2] * b[1] ; Index: sg.h =================================================================== RCS file: /cvsroot/plib/plib/src/sg/sg.h,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- sg.h 13 Jun 2002 05:53:02 -0000 1.35 +++ sg.h 14 Jun 2002 04:38:23 -0000 1.36 @@ -62,7 +62,27 @@ inline SGfloat sgSqrt ( const SGfloat x ) { return (SGfloat) sqrt ( x ) ; } inline SGfloat sgSquare ( const SGfloat x ) { return x * x ; } -inline SGfloat sgAbs ( const SGfloat a ) { return ( a < SG_ZERO ) ? -a : a ; } +inline SGfloat sgAbs ( const SGfloat a ) { return (a<SG_ZERO) ? -a : a ; } + +/* + Type-casted sin/cos/tan/asin/acos/atan2 ANGLES IN DEGREES +*/ + +inline SGfloat sgASin ( SGfloat s ) + { return (SGfloat) asin ( s ) * SG_RADIANS_TO_DEGREES ; } +inline SGfloat sgACos ( SGfloat s ) + { return (SGfloat) acos ( s ) * SG_RADIANS_TO_DEGREES ; } +inline SGfloat sgATan ( SGfloat s ) + { return (SGfloat) atan ( s ) * SG_RADIANS_TO_DEGREES ; } +inline SGfloat sgATan2 ( SGfloat y, SGfloat x ) + { return (SGfloat) atan2 ( y,x ) * SG_RADIANS_TO_DEGREES ; } +inline SGfloat sgSin ( SGfloat s ) + { return (SGfloat) sin ( s * SG_DEGREES_TO_RADIANS ) ; } +inline SGfloat sgCos ( SGfloat s ) + { return (SGfloat) cos ( s * SG_DEGREES_TO_RADIANS ) ; } +inline SGfloat sgTan ( SGfloat s ) + { return (SGfloat) tan ( s * SG_DEGREES_TO_RADIANS ) ; } + inline int sgCompareFloat ( const SGfloat a, const SGfloat b, const SGfloat tol ) { @@ -800,14 +820,14 @@ inline SGfloat sgDistToLineVec3 ( const sgLine3 line, const sgVec3 pnt ) { - return (SGfloat) sqrt ( (double) sgDistSquaredToLineVec3 ( line, pnt ) ); + return sgSqrt ( sgDistSquaredToLineVec3 ( line, pnt ) ); } inline SGfloat sgDistToLineSegmentVec3 ( const sgLineSegment3 line, const sgVec3 pnt ) { - return (SGfloat) sqrt ( (double) sgDistSquaredToLineSegmentVec3(line,pnt) ) ; + return sgSqrt ( sgDistSquaredToLineSegmentVec3(line,pnt) ) ; } @@ -1342,6 +1362,21 @@ inline SGDfloat sgdSqrt ( const SGDfloat x ) { return sqrt ( x ) ; } inline SGDfloat sgdSquare ( const SGDfloat x ) { return x * x ; } inline SGDfloat sgdAbs ( const SGDfloat a ) { return ( a < SGD_ZERO ) ? -a : a ; } + +inline SGDfloat sgdASin ( SGDfloat s ) + { return (SGDfloat) asin ( s ) * SGD_RADIANS_TO_DEGREES ; } +inline SGDfloat sgdACos ( SGDfloat s ) + { return (SGDfloat) acos ( s ) * SGD_RADIANS_TO_DEGREES ; } +inline SGDfloat sgdATan ( SGDfloat s ) + { return (SGDfloat) atan ( s ) * SGD_RADIANS_TO_DEGREES ; } +inline SGDfloat sgdATan2 ( SGDfloat y, SGDfloat x ) + { return (SGDfloat) atan2 ( y,x ) * SGD_RADIANS_TO_DEGREES ; } +inline SGDfloat sgdSin ( SGDfloat s ) + { return (SGDfloat) sin ( s * SGD_DEGREES_TO_RADIANS ) ; } +inline SGDfloat sgdCos ( SGDfloat s ) + { return (SGDfloat) cos ( s * SGD_DEGREES_TO_RADIANS ) ; } +inline SGDfloat sgdTan ( SGDfloat s ) + { return (SGDfloat) tan ( s * SGD_DEGREES_TO_RADIANS ) ; } inline int sgdCompareFloat ( const SGDfloat a, const SGDfloat b, const SGDfloat tol ) { |