From: <pat...@us...> - 2011-03-27 17:26:35
|
Revision: 1270 http://ggt.svn.sourceforge.net/ggt/?rev=1270&view=rev Author: patrickh Date: 2011-03-27 17:26:29 +0000 (Sun, 27 Mar 2011) Log Message: ----------- Added a new Sphere/Sphere intersection function. Submitted by: Sebastian Messerschmidt Modified Paths: -------------- trunk/ChangeLog trunk/gmtl/Intersection.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-03-27 17:24:47 UTC (rev 1269) +++ trunk/ChangeLog 2011-03-27 17:26:29 UTC (rev 1270) @@ -1,5 +1,7 @@ DATE AUTHOR CHANGE ---------- ------------ ------------------------------------------------------- +2011-03-27 patrickh Added a new Sphere/Sphere intersection function. + Submitted by Sebastian Messerschmidt 2010-11-21 patrickh gmtl.pc is once again generated for pkg-config usage. [0.6.1 released - 5.20.2010]=================================================== Modified: trunk/gmtl/Intersection.h =================================================================== --- trunk/gmtl/Intersection.h 2011-03-27 17:24:47 UTC (rev 1269) +++ trunk/gmtl/Intersection.h 2011-03-27 17:26:29 UTC (rev 1270) @@ -48,6 +48,25 @@ } /** + * Tests if the given spheres intersect or touch. + * + * @param sphere1 first sphere + * @param sphere2 second sphere + * + * @return true if the spheres intersect or touch + * + * @since 0.7.0 + */ + template <class DATA_TYPE> + bool intersect(const Sphere<DATA_TYPE>& sphere1, + const Sphere<DATA_TYPE>& sphere2) + { + Vec<DATA_TYPE, 3> relativePosition(sphere1.mCenter - sphere2.mCenter); + DATA_TYPE distance = lengthSquared(relativePosition); + return distance <= (sphere1.mRadius + sphere2.mRadius) * (sphere1.mRadius + sphere2.mRadius); + } + + /** * Tests if the given AABox and point intersect with each other. On an edge IS * considered intersection by this algorithm. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |