Math/Vector[2|3]: Removed Distancef and made Distance templated

This commit is contained in:
Jérôme Leclercq
2018-07-02 18:13:14 +02:00
parent 7da0fffe07
commit e4b67019cb
6 changed files with 39 additions and 57 deletions

View File

@@ -124,22 +124,10 @@ namespace Nz
*/
template<typename T>
T Vector2<T>::Distance(const Vector2& vec) const
template<typename U>
U Vector2<T>::Distance(const Vector2& vec) const
{
return std::sqrt(SquaredDistance(vec));
}
/*!
* \brief Calculates the distance between two vectors
* \return The metric distance in float between two vectors with euclidean norm
*
* \param vec The other vector to measure the distance with
*/
template<typename T>
float Vector2<T>::Distancef(const Vector2& vec) const
{
return std::sqrt(static_cast<float>(SquaredDistance(vec)));
return static_cast<U>(std::sqrt(SquaredDistance(vec)));
}
/*!
@@ -835,6 +823,24 @@ namespace Nz
return !operator<(vec);
}
/*!
* \brief Measure the distance between two points
* Shorthand for vec1.Distance(vec2)
*
* param vec1 the first point
* param vec2 the second point
*
* \return The distance between the two vectors
*
* \see SquaredDistance
*/
template<typename T>
template<typename U>
U Vector2<T>::Distance(const Vector2& vec1, const Vector2& vec2)
{
return vec1.Distance<U>(vec2);
}
/*!
* \brief Calculates the dot (scalar) product with two vectors
* \return The value of the dot product