diff --git a/libraries/AP_Math/polygon.cpp b/libraries/AP_Math/polygon.cpp index 3b394b7b6c..c34b9abbbf 100644 --- a/libraries/AP_Math/polygon.cpp +++ b/libraries/AP_Math/polygon.cpp @@ -35,7 +35,8 @@ * expect that to be very small over the distances involved in the * fence boundary */ -bool Polygon_outside(const Vector2l &P, const Vector2l *V, unsigned n) +template +bool Polygon_outside(const Vector2 &P, const Vector2 *V, unsigned n) { unsigned i, j; bool outside = true; @@ -85,7 +86,14 @@ bool Polygon_outside(const Vector2l &P, const Vector2l *V, unsigned n) * and the first point is the same as the last point. That is the * minimum requirement for the Polygon_outside function to work */ -bool Polygon_complete(const Vector2l *V, unsigned n) +template +bool Polygon_complete(const Vector2 *V, unsigned n) { return (n >= 4 && V[n-1].x == V[0].x && V[n-1].y == V[0].y); } + +// Necessary to avoid linker errors +template bool Polygon_outside(const Vector2l &P, const Vector2l *V, unsigned n); +template bool Polygon_complete(const Vector2l *V, unsigned n); +template bool Polygon_outside(const Vector2f &P, const Vector2f *V, unsigned n); +template bool Polygon_complete(const Vector2f *V, unsigned n); diff --git a/libraries/AP_Math/polygon.h b/libraries/AP_Math/polygon.h index b8a5383800..ab70c43b57 100644 --- a/libraries/AP_Math/polygon.h +++ b/libraries/AP_Math/polygon.h @@ -20,6 +20,8 @@ #include "vector2.h" -bool Polygon_outside(const Vector2l &P, const Vector2l *V, unsigned n); -bool Polygon_complete(const Vector2l *V, unsigned n); +template +bool Polygon_outside(const Vector2 &P, const Vector2 *V, unsigned n); +template +bool Polygon_complete(const Vector2 *V, unsigned n);