[core] Add optional type template parameter to util::unit, so that it doesn't always pick up the default type of 'double' from util::mag.

This commit is contained in:
Chris Loer
2017-08-25 10:42:14 -07:00
committed by Chris Loer
parent fe8cbc78d3
commit 17a3a805f1

View File

@@ -77,9 +77,9 @@ T mag(const S& a) {
return std::sqrt(a.x * a.x + a.y * a.y);
}
template <typename S>
template <typename T = double, typename S>
S unit(const S& a) {
auto magnitude = mag(a);
auto magnitude = mag<T>(a);
if (magnitude == 0) {
return a;
}