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

[MathLib] Vector3: Reimpl. mult. with scalar.

parent 1792d9a2
No related branches found
No related tags found
No related merge requests found
...@@ -110,11 +110,15 @@ public: ...@@ -110,11 +110,15 @@ public:
TemplateVector3<T1> const& v, TemplateVector3<T1> const& v,
TemplateVector3<T1> const& w); TemplateVector3<T1> const& w);
TemplateVector3 operator*(double pR) const // * a scalar /** multiplication with a scalar s */
{ template <typename T1>
return TemplateVector3(this->x[0] * pR, this->x[1] * pR, this->x[2] * pR); friend TemplateVector3<T1> operator*(
} TemplateVector3<T1> const& v,
double s);
template <typename T1>
friend TemplateVector3<T1> operator*(
double s,
TemplateVector3<T1> const& v);
TemplateVector3& operator*=(double pR) TemplateVector3& operator*=(double pR)
{ {
...@@ -173,6 +177,20 @@ TemplateVector3<T1> crossProduct( ...@@ -173,6 +177,20 @@ TemplateVector3<T1> crossProduct(
v._x[0] * w._x[1] - v._x[1] * w._x[0]); v._x[0] * w._x[1] - v._x[1] * w._x[0]);
} }
template <typename T1> TemplateVector3<T1> operator*(
TemplateVector3<T1> const& v,
double s)
{
return TemplateVector3<T1>(v[0] * s, v[1] * s, v[2] * s);
}
template <typename T1> TemplateVector3<T1> operator*(
double s,
TemplateVector3<T1> const& v)
{
return v * s;
}
typedef TemplateVector3<double> Vector3; 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