Added SquaredDistance and made the point-plane version redirect to the plane-point one.

This commit is contained in:
Marco Di Benedetto 2009-10-06 16:22:35 +00:00
parent 06bda0acae
commit b17d165d0c
1 changed files with 17 additions and 5 deletions

View File

@ -174,14 +174,26 @@ public:
typedef Plane3<float> Plane3f;
typedef Plane3<double> Plane3d;
///Distance plane - point (Move this function to somewhere else)
template<class T> T Distance(const Plane3<T> &plane, const Point3<T> &point) {
///Distance plane - point and vv. (Move these function to somewhere else)
template<class T> T Distance(const Plane3<T> & plane, const Point3<T> & point)
{
return plane.Direction().dot(point) - plane.Offset();
}
///Distance point-plane (Move this function to somewhere else)
template<class T> T Distance(const Point3<T> &point, const Plane3<T> &plane) {
return plane.Direction().dot(point) - plane.Offset();
template<class T> T SquaredDistance(const Plane3<T> & plane, const Point3<T> & point)
{
const T d = Distance(plane, point);
return (d * d);
}
template<class T> T Distance(const Point3<T> & point, const Plane3<T> & plane)
{
return Distance(plane, point);
}
template<class T> T SquaredDistance(const Point3<T> & point, const Plane3<T> & plane)
{
return SquaredDistance(plane, point);
}
} // end namespace