Browse Source

AP_Math: vector2f::length_squared always returns float

master
Andrew Tridgell 6 years ago committed by Randy Mackay
parent
commit
4c4de1f021
  1. 7
      libraries/AP_Math/vector2.cpp
  2. 5
      libraries/AP_Math/vector2.h

7
libraries/AP_Math/vector2.cpp

@ -20,6 +20,12 @@ @@ -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 @@ -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;

5
libraries/AP_Math/vector2.h

@ -131,10 +131,7 @@ struct Vector2 @@ -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;

Loading…
Cancel
Save