Vector4 +, -, negation, and *
+, -, and negation were easy. Multiplication is wacky because the Matrix class does it. So, to do binary * (not *=) I needed to dynamic_cast the resulting Matrix<4,1> to a Vector4&&.
This commit is contained in:
parent
a3d51f7cf3
commit
b41cdb7186
2 changed files with 94 additions and 0 deletions
|
@ -32,6 +32,15 @@ struct Vector4
|
|||
Double& Z();
|
||||
const Double& Z() const;
|
||||
|
||||
Vector4 operator*(const Double& rhs) const;
|
||||
|
||||
Vector4 operator+(const Vector4& rhs) const;
|
||||
Vector4& operator+=(const Vector4& rhs);
|
||||
Vector4 operator-(const Vector4& rhs) const;
|
||||
Vector4& operator-=(const Vector4& rhs);
|
||||
|
||||
Vector4 operator-() const;
|
||||
|
||||
/** Get the length-squared of this vector. */
|
||||
Double Length2() const;
|
||||
|
||||
|
@ -49,6 +58,10 @@ struct Vector4
|
|||
};
|
||||
|
||||
|
||||
/** Scalar multiplication of vectors, with the scalar factor on the left. */
|
||||
Vector4 operator*(const Double& lhs, const Vector4& rhs);
|
||||
|
||||
|
||||
/** Normalize the given vector and return a copy of it. */
|
||||
Vector4& Normalized(const Vector4& v);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue