tiny additions in vec.h and vecmat3.h
This commit is contained in:
parent
e75248eb23
commit
764baa3201
8
vec.h
8
vec.h
@ -363,6 +363,14 @@ public:
|
|||||||
return sum;
|
return sum;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! compute the sum of squares the vector elements
|
||||||
|
inline const T sumsqr() const {
|
||||||
|
T sum(v[0]);
|
||||||
|
for(register int i=1; i<nn; i++){ sum += v[i]*v[i];}
|
||||||
|
return sum;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//! compute the product of the vector elements
|
//! compute the product of the vector elements
|
||||||
inline const T prod() const {
|
inline const T prod() const {
|
||||||
T prod(v[0]);
|
T prod(v[0]);
|
||||||
|
@ -79,6 +79,10 @@ public:
|
|||||||
Vec3& operator/=(const T rhs) {return *this *= ((T)1/rhs);};
|
Vec3& operator/=(const T rhs) {return *this *= ((T)1/rhs);};
|
||||||
const Vec3 operator*(const T rhs) const {return Vec3(*this) *= rhs;};
|
const Vec3 operator*(const T rhs) const {return Vec3(*this) *= rhs;};
|
||||||
const Vec3 operator/(const T rhs) const {return Vec3(*this) /= rhs;};
|
const Vec3 operator/(const T rhs) const {return Vec3(*this) /= rhs;};
|
||||||
|
T sum() const {return q[0]+q[1]+q[2];};
|
||||||
|
T asum() const {return abs(q[0])+abs(q[1])+abs(q[2]);};
|
||||||
|
T sumsqr() const {return q[0]*q[0]+q[1]*q[1]+q[2]*q[2];};
|
||||||
|
T prod() const {return q[0]*q[1]*q[2];};
|
||||||
|
|
||||||
//Vec3 algebra
|
//Vec3 algebra
|
||||||
const Vec3 operator-() const {Vec3 r(*this); r.q[0]= -r.q[0]; r.q[1]= -r.q[1]; r.q[2]= -r.q[2]; return r;}; //unary minus
|
const Vec3 operator-() const {Vec3 r(*this); r.q[0]= -r.q[0]; r.q[1]= -r.q[1]; r.q[2]= -r.q[2]; return r;}; //unary minus
|
||||||
|
Loading…
Reference in New Issue
Block a user