Skip to content
Snippets Groups Projects
Commit a315384a authored by Tom Fischer's avatar Tom Fischer
Browse files

[MathLib] Vector3: Reimpl. crossProduct() as a friend.

parent eee2e109
No related branches found
No related tags found
No related merge requests found
......@@ -102,14 +102,13 @@ public:
template <typename T1>
friend T1 scalarProduct(TemplateVector3<T1> const& v, TemplateVector3<T1> const& w);
/// Cross product as the multiplication operator
TemplateVector3 operator*(const TemplateVector3 & pV) const
{
return TemplateVector3 (
this->_x[1] * pV[2] - this->_x[2] * pV[1],
this->_x[2] * pV[0] - this->_x[0] * pV[2],
this->_x[0] * pV[1] - this->_x[1] * pV[0] );
}
/** crossProduct: implementation of cross product,
* sometimes called outer product.
*/
template <typename T1>
friend TemplateVector3<T1> crossProduct(
TemplateVector3<T1> const& v,
TemplateVector3<T1> const& w);
/// Cross product with another vector
TemplateVector3 Cross( const TemplateVector3 & pV ) const
......@@ -174,6 +173,17 @@ T scalarProduct(TemplateVector3<T> const& v, TemplateVector3<T> const& w)
return v._x[0] * w._x[0] + v._x[1] * w._x[1] + v._x[2] * w._x[2];
}
template <typename T1>
TemplateVector3<T1> crossProduct(
TemplateVector3<T1> const& v,
TemplateVector3<T1> const& w)
{
return TemplateVector3<T1>(
v._x[1] * w._x[2] - v._x[2] * w._x[1],
v._x[2] * w._x[0] - v._x[0] * w._x[2],
v._x[0] * w._x[1] - v._x[1] * w._x[0]);
}
typedef TemplateVector3<double> Vector3;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment