Math/Sphere: Fix (Squared)Distance

Former-commit-id: d91c0d6e8a193e47c3ed45babaf3b83bf1cbe7ee
This commit is contained in:
Lynix
2015-06-17 23:35:06 +02:00
parent 80208b0dc5
commit 35066a3451
3 changed files with 25 additions and 6 deletions

View File

@@ -68,14 +68,13 @@ bool NzSphere<T>::Contains(const NzVector3<T>& point) const
template<typename T>
T NzSphere<T>::Distance(T X, T Y, T Z) const
{
NzVector3<T> distance(X-x, Y-y, Z-z);
return distance.GetLength();
return Distance({X, Y, Z});
}
template<typename T>
T NzSphere<T>::Distance(const NzVector3<T>& point) const
{
return Distance(point.x, point.y, point.z);
return NzVector3f::Distance(point, GetPosition()) - radius;
}
template<typename T>
@@ -249,14 +248,13 @@ NzSphere<T>& NzSphere<T>::Set(const NzSphere<U>& sphere)
template<typename T>
T NzSphere<T>::SquaredDistance(T X, T Y, T Z) const
{
NzVector3<T> distance(X-x, Y-y, Z-z);
return distance.GetSquaredLength();
return SquaredDistance({X, Y, Z});
}
template<typename T>
T NzSphere<T>::SquaredDistance(const NzVector3<T>& point) const
{
return SquaredDistance(point.x, point.y, point.z);
return NzVector3f::Distance(point, GetPosition()) - radius * radius;
}
template<typename T>