git-svn-id: svn://db.shs.com.ru/pip@201 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIMathVector
|
||||
Copyright (C) 2015 Ivan Pelipenko peri4ko@gmail.com
|
||||
Copyright (C) 2016 Ivan Pelipenko peri4ko@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -96,12 +96,13 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
operator PIMathMatrixT<1, Size, Type>() {return transposed();}
|
||||
operator PIMathMatrixT<Size, 1, Type>() {
|
||||
PIMathMatrixT<Size, 1, Type> ret;
|
||||
PIMV_FOR(i, 0) ret[i][0] = c[i];
|
||||
return ret;
|
||||
}
|
||||
// operator PIMathMatrixT<1, Size, Type>() {return transposed();}
|
||||
// operator PIMathMatrixT<Size, 1, Type>() {
|
||||
// PIMathMatrixT<Size, 1, Type> ret;
|
||||
// PIMV_FOR(i, 0) ret[i][0] = c[i];
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
Type distToLine(const _CVector & lp0, const _CVector & lp1) {
|
||||
_CVector a(lp0, lp1), b(lp0, *this), c(lp1, *this);
|
||||
Type f = fabs(a[0]*b[1] - a[1]*b[0]) / a.length();//, s = b.length() + c.length() - a.length();
|
||||
@@ -110,6 +111,8 @@ public:
|
||||
template<uint Size1, typename Type1> /// vector {Size, Type} to vector {Size1, Type1}
|
||||
PIMathVectorT<Size1, Type1> turnTo() const {PIMathVectorT<Size1, Type1> tv; uint sz = piMin<uint>(Size, Size1); for (uint i = 0; i < sz; ++i) tv[i] = c[i]; return tv;}
|
||||
|
||||
static _CVector filled(const Type & v) {_CVector vv; PIMV_FOR(i, 0) vv[i] = v; return vv;}
|
||||
|
||||
private:
|
||||
void resize(const Type & new_value = Type()) {for (int i = 0; i < Size; ++i) c[i] = new_value;}
|
||||
|
||||
@@ -118,6 +121,11 @@ private:
|
||||
};
|
||||
//#pragma pack(pop)
|
||||
|
||||
template<uint Size, typename Type>
|
||||
inline PIMathVectorT<Size, Type> operator *(const Type & x, const PIMathVectorT<Size, Type> & v) {
|
||||
return v * x;
|
||||
}
|
||||
|
||||
template<uint Size, typename Type>
|
||||
inline std::ostream & operator <<(std::ostream & s, const PIMathVectorT<Size, Type> & v) {s << '{'; PIMV_FOR(i, 0) {s << v[i]; if (i < Size - 1) s << ", ";} s << '}'; return s;}
|
||||
template<uint Size, typename Type>
|
||||
@@ -228,6 +236,4 @@ inline PICout operator <<(PICout s, const PIMathVector<Type> & v) {s << '{'; for
|
||||
typedef PIMathVector<int> PIMathVectori;
|
||||
typedef PIMathVector<double> PIMathVectord;
|
||||
|
||||
//#include "pimathmatrix.h"
|
||||
|
||||
#endif // PIMATHVECTOR_H
|
||||
|
||||
Reference in New Issue
Block a user