vector: instantiate polar_to_cartesian

This commit is contained in:
Danny Robson 2015-04-01 17:05:24 +11:00
parent ea36bae110
commit 3da59aea2f
2 changed files with 7 additions and 4 deletions

View File

@ -101,10 +101,10 @@ util::vector<S,T>::normalised (void) const {
//-----------------------------------------------------------------------------
template <typename T>
util::vector<2,T>
util::polar_to_cartesian (const util::vector<2,T> &v) {
util::polar_to_cartesian (util::vector<2,T> v) {
return util::vector<2,T> {
v.r * std::cos (v.t),
v.r * std::sin (v.t)
v[0] * std::cos (v[1]),
v[0] * std::sin (v[1])
};
}
@ -232,8 +232,11 @@ INSTANTIATE(int64_t)
INSTANTIATE(float)
INSTANTIATE(double)
//-----------------------------------------------------------------------------
namespace util {
template vector<2,float> polar_to_cartesian (util::vector<2,float>);
template <> vector<1,float> random (void) { util::vector<1,float> out; randomise (out.data); return out; }
template <> vector<2,float> random (void) { util::vector<2,float> out; randomise (out.data); return out; }
template <> vector<3,float> random (void) { util::vector<3,float> out; randomise (out.data); return out; }

View File

@ -56,7 +56,7 @@ namespace util {
};
// free vector operators
template <typename T> vector<2,T> polar_to_cartesian (const vector<2,T>&);
template <typename T> vector<2,T> polar_to_cartesian (vector<2,T>);
template <typename T> vector<3,T> cross (const vector<3,T>&, const vector<3,T>&);
template <typename T> vector<3,T> spherical_to_cartesian (const vector<3,T>&);