g-truc/glm — pull request #10 by boromisp (2012-11-11 23:40:53+00:00)
Title: Sphere intersection fixes

This is a fix for the https://github.com/g-truc/glm/issues/8

* Completely rewrote the ray-sphere intersection, changed the analytic method to geometric, it should perform slightly better.
* Added a new overloaded function to calculate only the distance of the ray-sphere intersection. Most of the time this is all we need.
``` c++
template
bool intersectRaySphere(
genType const & rayStarting, genType const & rayNormalizedDirection,
genType const & sphereCenter, const typename genType::value_type sphereRadiusSquered,
typename genType::value_type & intersectionDistance);
```

* Changed the line-sphere function to return both intersection points, so its not a duplicate of the ray-sphere function anymore.
``` c++
template
bool intersectLineSphere(
genType const & point0, genType const & point1,
genType const & sphereCenter, typename genType::value_type sphereRadius,
genType & intersectionPosition1, genType & intersectionNormal1,
genType & intersectionPosition2, genType & intersectionNormal2);
```

* Changed the parameter names to verbose in all three functions, so the preconditions are clear.