force used the double type at length_squared_2d.

This commit is contained in:
hyzboy 2020-11-16 16:50:40 +08:00
parent 0bcfed4e93
commit 16f8e89f5b

View File

@ -185,6 +185,7 @@ namespace hgl
{ {
return sqrt(length_squared(v1-v2)); return sqrt(length_squared(v1-v2));
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline float length_squared(const T1 &v1, const T2 &v2) inline float length_squared(const T1 &v1, const T2 &v2)
{ {
@ -194,8 +195,8 @@ namespace hgl
template<typename T1, typename T2> template<typename T1, typename T2>
inline float length_squared_2d(const T1 &v1, const T2 &v2) inline float length_squared_2d(const T1 &v1, const T2 &v2)
{ {
const float x = (v1.x - v2.x); const double x = double(v1.x) - double(v2.x);
const float y = (v1.y - v2.y); const double y = double(v1.y) - double(v2.y);
return x*x + y*y; return x*x + y*y;
} }