Add polar to cartesian operation for vectors

This commit is contained in:
Danny Robson 2013-07-30 23:52:31 +10:00
parent 1f37a8d04c
commit b4228aca1e
2 changed files with 8 additions and 3 deletions

View File

@ -266,6 +266,12 @@ util::vector<S>::normalised (void) const {
return out;
}
//-----------------------------------------------------------------------------
util::vector<2>
util::polar_to_cartesian (const util::vector<2> &v) {
return { v.r * std::cos (v.t),
v.r * std::sin (v.t) };
}
//-----------------------------------------------------------------------------
template <size_t S>

View File

@ -78,16 +78,15 @@ namespace util {
void sanity (void) const;
};
vector<3> cross (const vector<3>&, const vector<3>&);
vector<2> polar_to_cartesian (const vector<2>&);
vector<3> cross (const vector<3>&, const vector<3>&);
vector<3> spherical_to_cartesian (const util::vector <3>&);
vector<3> cartesian_to_spherical (const util::vector <3>&);
typedef vector<2> vector2;
typedef vector<3> vector3;
template <size_t S> util::vector<S> operator* (double, const util::vector<S>&);
template <size_t S> util::vector<S> operator+ (double, const util::vector<S>&);
template <size_t S> util::vector<S> operator- (double, const util::vector<S>&);