vector: add 2d cross product
This commit is contained in:
parent
fde9b281be
commit
a7caea16e1
@ -41,6 +41,11 @@ namespace util {
|
|||||||
vector<3,T>
|
vector<3,T>
|
||||||
cross (vector<3,T>, vector<3,T>);
|
cross (vector<3,T>, vector<3,T>);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr
|
||||||
|
T
|
||||||
|
cross (vector<2,T>, vector<2,T>);
|
||||||
|
|
||||||
// polar/cartesian conversions; assumes (mag, angle) form.
|
// polar/cartesian conversions; assumes (mag, angle) form.
|
||||||
template <typename T> vector<2,T> polar_to_cartesian (vector<2,T>);
|
template <typename T> vector<2,T> polar_to_cartesian (vector<2,T>);
|
||||||
template <typename T> vector<2,T> cartesian_to_polar (vector<2,T>);
|
template <typename T> vector<2,T> cartesian_to_polar (vector<2,T>);
|
||||||
|
10
vector.ipp
10
vector.ipp
@ -48,6 +48,16 @@ util::cross (util::vector<3,T> a, util::vector<3,T> b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
constexpr
|
||||||
|
T
|
||||||
|
util::cross (util::vector<2,T> a, util::vector<2,T> b)
|
||||||
|
{
|
||||||
|
return a[0] * b[1] - a[1] * b[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
template <size_t S, typename T>
|
template <size_t S, typename T>
|
||||||
constexpr
|
constexpr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user