[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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user