pimathvector.h mul

This commit is contained in:
2020-10-21 18:36:57 +03:00
parent 7b5555f63d
commit 6f3fdf4d49
2 changed files with 52 additions and 7 deletions

View File

@@ -149,6 +149,14 @@ public:
PIMV_FOR tv += c[i] * v[i]; PIMV_FOR tv += c[i] * v[i];
return tv; return tv;
} }
_CVector mul(const _CVector & v) const {
_CVector tv(*this);
PIMV_FOR tv[i] *= v[i];
return tv;
}
_CVector mul(const Type & v) const {
return (*this) * v;
}
PIMathMatrixT<1, Size, Type> transposed() const { PIMathMatrixT<1, Size, Type> transposed() const {
PIMathMatrixT<1, Size, Type> ret; PIMathMatrixT<1, Size, Type> ret;
@@ -172,6 +180,22 @@ public:
return tv; return tv;
} }
static _CVector cross(const _CVector & v1, const _CVector & v2) {
return v1.cross(v2);
}
static _CVector dot(const _CVector & v1, const _CVector & v2) {
return v1.dot(v2);
}
static _CVector mul(const _CVector & v1, const _CVector & v2) {
return v1.mul(v2);
}
static _CVector mul(const Type & v1, const _CVector & v2) {
return v2 * v1;
}
static _CVector mul(const _CVector & v1, const Type & v2) {
return v1 * v2;
}
private: private:
Type c[Size]; Type c[Size];
@@ -372,6 +396,15 @@ public:
PIMV_FOR tv += c[i] * v[i]; PIMV_FOR tv += c[i] * v[i];
return tv; return tv;
} }
_CVector mul(const _CVector & v) const {
assert(c.size() == v.size());
_CVector tv(*this);
PIMV_FOR tv[i] *= v[i];
return tv;
}
_CVector mul(const Type & v) const {
return (*this) * v;
}
Type distToLine(const _CVector & lp0, const _CVector & lp1) { Type distToLine(const _CVector & lp0, const _CVector & lp1) {
assert(c.size() == lp0.size()); assert(c.size() == lp0.size());
@@ -388,9 +421,24 @@ public:
inline Type * data() {return c.data();} inline Type * data() {return c.data();}
inline const Type * data() const {return c.data();} inline const Type * data() const {return c.data();}
static _CVector cross(const _CVector & v1, const _CVector & v2) {
return v1.cross(v2);
}
static _CVector dot(const _CVector & v1, const _CVector & v2) {
return v1.dot(v2);
}
static _CVector mul(const _CVector & v1, const _CVector & v2) {
return v1.mul(v2);
}
static _CVector mul(const Type & v1, const _CVector & v2) {
return v2 * v1;
}
static _CVector mul(const _CVector & v1, const Type & v2) {
return v1 * v2;
}
private: private:
PIVector<Type> c; PIVector<Type> c;
}; };
template<typename Type> template<typename Type>

View File

@@ -40,11 +40,8 @@ inline PIByteArray & operator >>(PIByteArray & ba, MM & v) {piCout << ">>"
int main() { int main() {
PIMathMatrixd m = PIMathMatrixd::identity(5,5); PIMathVectorT3d v3 = createVectorT3d(1,2,3);
// m.fill(9); PIMathVectord v(v3);
//PIMathMatrixd m2 = PIMathMatrixd::identity(3,4); piCout << v;
piCout << m;
m.resize(3,3);
piCout << m;
return 0; return 0;
} }