Math/Plane: Rename Distance method to SignedDistance

This commit is contained in:
SirLynix
2023-06-22 17:56:18 +02:00
parent 8481cc7c15
commit b2538028b4
6 changed files with 29 additions and 48 deletions

View File

@@ -113,22 +113,17 @@ namespace Nz
return NumberEquals(distance, plane.distance, maxDifference);
}
/*!
* \brief Returns the distance from the plane to the point
* \return Distance to the point
*
* \param x X position of the point
* \param y Y position of the point
* \param z Z position of the point
*
* \remark If T is negative, it means that the point is in the opposite direction of the normal
*
* \see Distance
*/
template<typename T>
constexpr T Plane<T>::Distance(T x, T y, T z) const
Plane<T>& Plane<T>::Normalize(T* length)
{
return Distance(Vector3<T>(x, y, z));
T normalLength = normal.GetLength();
normal /= normalLength;
distance /= normalLength;
if (length)
*length = normalLength;
return *this;
}
/*!
@@ -142,24 +137,11 @@ namespace Nz
* \see Distance
*/
template<typename T>
constexpr T Plane<T>::Distance(const Vector3<T>& point) const
constexpr T Plane<T>::SignedDistance(const Vector3<T>& point) const
{
return normal.DotProduct(point) + distance; // ax + by + cz + d = 0.
}
template<typename T>
Plane<T>& Plane<T>::Normalize(T* length)
{
T normalLength = normal.GetLength();
normal /= normalLength;
distance /= normalLength;
if (length)
*length = normalLength;
return *this;
}
/*!
* \brief Gives a string representation
* \return A string representation of the object: "Plane(Normal: Vector3(x, y, z); Distance: w)"