AP_Math: vector2f::length_squared always returns float

This commit is contained in:
Andrew Tridgell 2019-05-29 20:16:12 +09:00 committed by Randy Mackay
parent 46617e6c72
commit 4c4de1f021
2 changed files with 8 additions and 4 deletions

View File

@ -20,6 +20,12 @@
#include "AP_Math.h"
template <typename T>
float Vector2<T>::length_squared() const
{
return (float)(x*x + y*y);
}
template <typename T>
float Vector2<T>::length(void) const
{
@ -244,6 +250,7 @@ bool Vector2<T>::circle_segment_intersection(const Vector2<T>& seg_start, const
}
// only define for float
template float Vector2<float>::length_squared(void) const;
template float Vector2<float>::length(void) const;
template float Vector2<float>::operator *(const Vector2<float> &v) const;
template float Vector2<float>::operator %(const Vector2<float> &v) const;

View File

@ -131,10 +131,7 @@ struct Vector2
}
// gets the length of this vector squared
T length_squared() const
{
return (T)(*this * *this);
}
float length_squared() const;
// gets the length of this vector
float length(void) const;