fix a bug, it's adaptive a error vector type.

This commit is contained in:
2020-11-12 16:12:11 +08:00
parent 4014c119cb
commit 0bcfed4e93

View File

@@ -180,28 +180,15 @@ namespace hgl
return sqrt(length_squared_2d(v));
}
template<typename T1, typename T2>
inline float length_squared(const T1 &v1, const T2 &v2)
{
const float x = (v1.x - v2.x);
const float y = (v1.y - v2.y);
return x*x + y*y;
}
template<typename T1, typename T2>
inline float length(const T1 &v1, const T2 &v2)
{
return sqrt(length_squared(v1, v2));
return sqrt(length_squared(v1-v2));
}
inline float length_squared(const Vector3f &v1, const Vector3f &v2)
template<typename T1, typename T2>
inline float length_squared(const T1 &v1, const T2 &v2)
{
const float x = (v1.x - v2.x);
const float y = (v1.y - v2.y);
const float z = (v1.z - v2.z);
return x*x + y*y + z*z;
return length_squared(v1-v2);
}
template<typename T1, typename T2>
@@ -213,11 +200,6 @@ namespace hgl
return x*x + y*y;
}
inline float length(const Vector3f &v1, const Vector3f &v2)
{
return sqrt(length_squared(v1, v2));
}
template<typename T1, typename T2>
inline float length_2d(const T1 &v1, const T2 &v2)
{