diff --git a/include/osg/Vec2d b/include/osg/Vec2d index 9f9177590..b9ddd7178 100644 --- a/include/osg/Vec2d +++ b/include/osg/Vec2d @@ -94,14 +94,6 @@ 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 { @@ -116,14 +108,6 @@ 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 { @@ -189,5 +173,18 @@ class Vec2d }; // end of class Vec2d + +/** multiply by vector components. */ +inline Vec2d componentMultiply(const Vec2d& lhs, const Vec2d& rhs) +{ + return Vec2d(lhs[0]*rhs[0], lhs[1]*rhs[1]); +} + +/** divide rhs components by rhs vector components. */ +inline Vec2d componentDivide(const Vec2d& lhs, const Vec2d& rhs) +{ + return Vec2d(lhs[0]/rhs[0], lhs[1]/rhs[1]); +} + } // end of namespace osg #endif diff --git a/include/osg/Vec2f b/include/osg/Vec2f index 5ca8446c2..0a059df5b 100644 --- a/include/osg/Vec2f +++ b/include/osg/Vec2f @@ -91,14 +91,6 @@ 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 { @@ -113,14 +105,6 @@ 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 { @@ -186,6 +170,18 @@ class Vec2f }; // end of class Vec2f +/** multiply by vector components. */ +inline Vec2f componentMultiply(const Vec2f& lhs, const Vec2f& rhs) +{ + return Vec2f(lhs[0]*rhs[0], lhs[1]*rhs[1]); +} + +/** divide rhs components by rhs vector components. */ +inline Vec2f componentDivide(const Vec2f& lhs, const Vec2f& rhs) +{ + return Vec2f(lhs[0]/rhs[0], lhs[1]/rhs[1]); +} + } // end of namespace osg #endif diff --git a/include/osg/Vec2s b/include/osg/Vec2s index 414a47ff8..a8e743c8e 100644 --- a/include/osg/Vec2s +++ b/include/osg/Vec2s @@ -98,13 +98,6 @@ class Vec2s return Vec2s(_v[0]*rhs._v[0], _v[1]*rhs._v[1]); } - inline Vec2s& operator *= (const Vec2s& rhs) - { - _v[0] *= rhs._v[0]; - _v[1] *= rhs._v[1]; - return *this; - } - inline Vec2s operator + (const Vec2s& rhs) const { return Vec2s(_v[0]+rhs._v[0], _v[1]+rhs._v[1]); @@ -138,5 +131,18 @@ class Vec2s }; // end of class Vec2s + +/** multiply by vector components. */ +inline Vec2s componentMultiply(const Vec2s& lhs, const Vec2s& rhs) +{ + return Vec2s(lhs[0]*rhs[0], lhs[1]*rhs[1]); +} + +/** divide rhs components by rhs vector components. */ +inline Vec2s componentDivide(const Vec2s& lhs, const Vec2s& rhs) +{ + return Vec2s(lhs[0]/rhs[0], lhs[1]/rhs[1]); +} + } // end of namespace osg #endif diff --git a/include/osg/Vec3d b/include/osg/Vec3d index e50d9437a..7ec50a7ca 100644 --- a/include/osg/Vec3d +++ b/include/osg/Vec3d @@ -121,15 +121,6 @@ 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 { @@ -145,15 +136,6 @@ 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 { @@ -222,6 +204,18 @@ class Vec3d }; // end of class Vec3d +/** multiply by vector components. */ +inline Vec3d componentMultiply(const Vec3d& lhs, const Vec3d& rhs) +{ + return Vec3d(lhs[0]*rhs[0], lhs[1]*rhs[1], lhs[2]*rhs[2]); +} + +/** divide rhs components by rhs vector components. */ +inline Vec3d componentDivide(const Vec3d& lhs, const Vec3d& rhs) +{ + return Vec3d(lhs[0]/rhs[0], lhs[1]/rhs[1], lhs[2]/rhs[2]); +} + } // end of namespace osg #endif diff --git a/include/osg/Vec3f b/include/osg/Vec3f index f5d9a46f0..8d4693b44 100644 --- a/include/osg/Vec3f +++ b/include/osg/Vec3f @@ -116,15 +116,6 @@ 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 { @@ -140,15 +131,6 @@ 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 { @@ -217,6 +199,17 @@ class Vec3f }; // end of class Vec3f +/** multiply by vector components. */ +inline Vec3f componentMultiply(const Vec3f& lhs, const Vec3f& rhs) +{ + return Vec3f(lhs[0]*rhs[0], lhs[1]*rhs[1], lhs[2]*rhs[2]); +} + +/** divide rhs components by rhs vector components. */ +inline Vec3f componentDivide(const Vec3f& lhs, const Vec3f& rhs) +{ + return Vec3f(lhs[0]/rhs[0], lhs[1]/rhs[1], lhs[2]/rhs[2]); +} const Vec3f X_AXIS(1.0,0.0,0.0); const Vec3f Y_AXIS(0.0,1.0,0.0); diff --git a/include/osg/Vec3s b/include/osg/Vec3s index ab3d9a492..edcf0a24a 100644 --- a/include/osg/Vec3s +++ b/include/osg/Vec3s @@ -111,17 +111,6 @@ class Vec3s return Vec3s(_v[0]*rhs._v[0], _v[1]*rhs._v[1], _v[2]*rhs._v[2]); } - /** Unary vector multiply. Slightly more efficient because no temporary - * intermediate object. - */ - inline Vec3s& operator *= (const Vec3s& rhs) - { - _v[0] *= rhs._v[0]; - _v[1] *= rhs._v[1]; - _v[2] *= rhs._v[2]; - return *this; - } - /** Binary vector add. */ inline Vec3s operator + (const Vec3s& rhs) const { @@ -162,6 +151,19 @@ class Vec3s }; // end of class Vec3s + +/** multiply by vector components. */ +inline Vec3s componentMultiply(const Vec3s& lhs, const Vec3s& rhs) +{ + return Vec3s(lhs[0]*rhs[0], lhs[1]*rhs[1], lhs[2]*rhs[2]); +} + +/** divide rhs components by rhs vector components. */ +inline Vec3s componentDivide(const Vec3s& lhs, const Vec3s& rhs) +{ + return Vec3s(lhs[0]/rhs[0], lhs[1]/rhs[1], lhs[2]/rhs[2]); +} + } // end of namespace osg #endif diff --git a/include/osg/Vec4d b/include/osg/Vec4d index f03e19c9a..14c6569fd 100644 --- a/include/osg/Vec4d +++ b/include/osg/Vec4d @@ -151,16 +151,6 @@ 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 { @@ -177,16 +167,6 @@ 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 { @@ -299,6 +279,18 @@ inline Vec4d::value_type operator * (const Vec4f& lhs,const Vec3d& rhs) return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+lhs[3]; } +/** multiply by vector components. */ +inline Vec4d componentMultiply(const Vec4d& lhs, const Vec4d& rhs) +{ + return Vec4d(lhs[0]*rhs[0], lhs[1]*rhs[1], lhs[2]*rhs[2], lhs[3]*rhs[3]); +} + +/** divide rhs components by rhs vector components. */ +inline Vec4d componentDivide(const Vec4d& lhs, const Vec4d& rhs) +{ + return Vec4d(lhs[0]/rhs[0], lhs[1]/rhs[1], lhs[2]/rhs[2], lhs[3]/rhs[3]); +} + } // end of namespace osg #endif diff --git a/include/osg/Vec4f b/include/osg/Vec4f index 54f17c89d..70f416030 100644 --- a/include/osg/Vec4f +++ b/include/osg/Vec4f @@ -147,16 +147,6 @@ 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 { @@ -173,16 +163,6 @@ 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 { @@ -256,8 +236,6 @@ class Vec4f }; // end of class Vec4f - - /** Compute the dot product of a (Vec3,1.0) and a Vec4f. */ inline Vec4f::value_type operator * (const Vec3f& lhs,const Vec4f& rhs) { @@ -270,6 +248,18 @@ inline Vec4f::value_type operator * (const Vec4f& lhs,const Vec3f& rhs) return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+lhs[3]; } +/** multiply by vector components. */ +inline Vec4f componentMultiply(const Vec4f& lhs, const Vec4f& rhs) +{ + return Vec4f(lhs[0]*rhs[0], lhs[1]*rhs[1], lhs[2]*rhs[2], lhs[3]*rhs[3]); +} + +/** divide rhs components by rhs vector components. */ +inline Vec4f componentDivide(const Vec4f& lhs, const Vec4f& rhs) +{ + return Vec4f(lhs[0]/rhs[0], lhs[1]/rhs[1], lhs[2]/rhs[2], lhs[3]/rhs[3]); +} + } // end of namespace osg #endif diff --git a/include/osg/Vec4s b/include/osg/Vec4s index 68290ae33..1e1ded4ae 100644 --- a/include/osg/Vec4s +++ b/include/osg/Vec4s @@ -129,18 +129,6 @@ class Vec4s _v[2]*rhs._v[2], _v[3]*rhs._v[3]); } - /** Unary vector multiply. Slightly more efficient because no temporary - * intermediate object. - */ - inline Vec4s& operator *= (const Vec4s& rhs) - { - _v[0] *= rhs._v[0]; - _v[1] *= rhs._v[1]; - _v[2] *= rhs._v[2]; - _v[3] *= rhs._v[3]; - return *this; - } - /** Binary vector add. */ inline Vec4s operator + (const Vec4s& rhs) const { @@ -185,6 +173,19 @@ class Vec4s }; // end of class Vec4s + +/** multiply by vector components. */ +inline Vec4s componentMultiply(const Vec4s& lhs, const Vec4s& rhs) +{ + return Vec4s(lhs[0]*rhs[0], lhs[1]*rhs[1], lhs[2]*rhs[2], lhs[3]*rhs[3]); +} + +/** divide rhs components by rhs vector components. */ +inline Vec4s componentDivide(const Vec4s& lhs, const Vec4s& rhs) +{ + return Vec4s(lhs[0]/rhs[0], lhs[1]/rhs[1], lhs[2]/rhs[2], lhs[3]/rhs[3]); +} + } // end of namespace osg #endif