From Chris Hanson, " Adds support for Vec /= Vec and Vec *= Vec operators to Vec2/Vec3/Vec4 double and float

classes."
This commit is contained in:
Robert Osfield 2009-11-23 10:01:44 +00:00
parent d81d71fd97
commit 87452fe1b9
6 changed files with 108 additions and 0 deletions

View File

@ -94,6 +94,14 @@ class Vec2d
return *this;
}
/** Unary multiply by vector. */
inline Vec2d& operator *= (const Vec2d& rhs)
{
_v[0]*=rhs[0];
_v[1]*=rhs[1];
return *this;
}
/** Divide by scalar. */
inline const Vec2d operator / (value_type rhs) const
{
@ -108,6 +116,14 @@ class Vec2d
return *this;
}
/** Unary divide by vector. */
inline Vec2d& operator /= (const Vec2d& rhs)
{
_v[0]/=rhs[0];
_v[1]/=rhs[1];
return *this;
}
/** Binary vector add. */
inline const Vec2d operator + (const Vec2d& rhs) const
{

View File

@ -91,6 +91,14 @@ class Vec2f
return *this;
}
/** Unary multiply by vector. */
inline Vec2f& operator *= (const Vec2f& rhs)
{
_v[0]*=rhs[0];
_v[1]*=rhs[1];
return *this;
}
/** Divide by scalar. */
inline const Vec2f operator / (value_type rhs) const
{
@ -105,6 +113,14 @@ class Vec2f
return *this;
}
/** Unary divide by vector. */
inline Vec2f& operator /= (const Vec2f& rhs)
{
_v[0]/=rhs[0];
_v[1]/=rhs[1];
return *this;
}
/** Binary vector add. */
inline const Vec2f operator + (const Vec2f& rhs) const
{

View File

@ -121,6 +121,15 @@ class Vec3d
return *this;
}
/** Unary multiply by vector. */
inline Vec3d& operator *= (const Vec3d& rhs)
{
_v[0]*=rhs[0];
_v[1]*=rhs[1];
_v[2]*=rhs[2];
return *this;
}
/** Divide by scalar. */
inline const Vec3d operator / (value_type rhs) const
{
@ -136,6 +145,15 @@ class Vec3d
return *this;
}
/** Unary divide by vector. */
inline Vec3d& operator /= (const Vec3d& rhs)
{
_v[0]/=rhs[0];
_v[1]/=rhs[1];
_v[2]/=rhs[2];
return *this;
}
/** Binary vector add. */
inline const Vec3d operator + (const Vec3d& rhs) const
{

View File

@ -116,6 +116,15 @@ class Vec3f
return *this;
}
/** Unary multiply by vector. */
inline Vec3f& operator *= (const Vec3f& rhs)
{
_v[0]*=rhs[0];
_v[1]*=rhs[1];
_v[2]*=rhs[2];
return *this;
}
/** Divide by scalar. */
inline const Vec3f operator / (value_type rhs) const
{
@ -131,6 +140,15 @@ class Vec3f
return *this;
}
/** Unary divide by vector. */
inline Vec3f& operator /= (const Vec3f& rhs)
{
_v[0]/=rhs[0];
_v[1]/=rhs[1];
_v[2]/=rhs[2];
return *this;
}
/** Binary vector add. */
inline const Vec3f operator + (const Vec3f& rhs) const
{

View File

@ -151,6 +151,16 @@ class Vec4d
return *this;
}
/** Unary multiply by vector. */
inline Vec4d& operator *= (const Vec4d& rhs)
{
_v[0]*=rhs[0];
_v[1]*=rhs[1];
_v[2]*=rhs[2];
_v[3]*=rhs[3];
return *this;
}
/** Divide by scalar. */
inline Vec4d operator / (value_type rhs) const
{
@ -167,6 +177,16 @@ class Vec4d
return *this;
}
/** Unary divide by vector. */
inline Vec4d& operator /= (const Vec4d& rhs)
{
_v[0]/=rhs[0];
_v[1]/=rhs[1];
_v[2]/=rhs[2];
_v[3]/=rhs[3];
return *this;
}
/** Binary vector add. */
inline Vec4d operator + (const Vec4d& rhs) const
{

View File

@ -147,6 +147,16 @@ class Vec4f
return *this;
}
/** Unary multiply by vector. */
inline Vec4f& operator *= (const Vec4f& rhs)
{
_v[0]*=rhs[0];
_v[1]*=rhs[1];
_v[2]*=rhs[2];
_v[3]*=rhs[3];
return *this;
}
/** Divide by scalar. */
inline Vec4f operator / (value_type rhs) const
{
@ -163,6 +173,16 @@ class Vec4f
return *this;
}
/** Unary divide by vector. */
inline Vec4f& operator /= (const Vec4f& rhs)
{
_v[0]/=rhs[0];
_v[1]/=rhs[1];
_v[2]/=rhs[2];
_v[3]/=rhs[3];
return *this;
}
/** Binary vector add. */
inline Vec4f operator + (const Vec4f& rhs) const
{