git-svn-id: svn://db.shs.com.ru/pip@764 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -129,7 +129,7 @@ inline PIMathVectorT<Size, Type> operator *(const Type & x, const PIMathVectorT<
|
||||
}
|
||||
|
||||
template<uint Size, typename Type>
|
||||
inline PICout operator <<(PICout s, const PIMathVectorT<Size, Type> & v) {s << '{'; PIMV_FOR(i, 0) {s << v[i]; if (i < Size - 1) s << ", ";} s << '}'; return s;}
|
||||
inline PICout operator <<(PICout 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>
|
||||
inline bool operator ||(const PIMathVectorT<Size, Type> & f, const PIMathVectorT<Size, Type> & s) {return (f * s).isNull();}
|
||||
template<uint Size, typename Type>
|
||||
@@ -179,7 +179,7 @@ template<typename Type>
|
||||
class PIP_EXPORT PIMathVector {
|
||||
typedef PIMathVector<Type> _CVector;
|
||||
public:
|
||||
PIMathVector(const uint size = 3) {c.resize(size);}
|
||||
PIMathVector(const uint size = 0) {c.resize(size);}
|
||||
PIMathVector(const PIVector<Type> & val) {c.resize(val.size()); PIMV_FOR(i, 0) c[i] = val[i];}
|
||||
PIMathVector(const _CVector & st, const _CVector & fn) {c.resize(st.size()); PIMV_FOR(i, 0) c[i] = fn[i] - st[i];}
|
||||
|
||||
@@ -201,6 +201,8 @@ public:
|
||||
_CVector & normalize() {Type tv = length(); if (tv == Type(1)) return *this; if (piAbs<Type>(tv) <= Type(1E-100)) {fill(Type(0)); return *this;} PIMV_FOR(i, 0) c[i] /= tv; return *this;}
|
||||
_CVector normalized() {_CVector tv(*this); tv.normalize(); return tv;}
|
||||
bool isNull() const {PIMV_FOR(i, 0) if (c[i] != Type(0)) return false; return true;}
|
||||
bool isValid() const {return !c.isEmpty();}
|
||||
|
||||
bool isOrtho(const _CVector & v) const {return ((*this) ^ v) == Type(0);}
|
||||
|
||||
Type & at(uint index) {return c[index];}
|
||||
@@ -237,6 +239,9 @@ public:
|
||||
PIMathVector turnTo(uint size) const {PIMathVector<Type1> tv; uint sz = piMin<uint>(c.size(), size); for (uint i = 0; i < sz; ++i) tv[i] = c[i]; return tv;}
|
||||
PIVector<Type> toVector() const {return c;}
|
||||
|
||||
inline Type * data() {return c.data();}
|
||||
inline const Type * data() const {return c.data();}
|
||||
|
||||
private:
|
||||
// uint size_;
|
||||
PIVector<Type> c;
|
||||
@@ -247,11 +252,17 @@ private:
|
||||
|
||||
#ifdef PIP_STD_IOSTREAM
|
||||
template<typename Type>
|
||||
inline std::ostream & operator <<(std::ostream & s, const PIMathVector<Type> & v) {s << '{'; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << '}'; return s;}
|
||||
inline std::ostream & operator <<(std::ostream & s, const PIMathVector<Type> & v) {s << "{"; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << "}"; return s;}
|
||||
#endif
|
||||
|
||||
template<typename Type>
|
||||
inline PICout operator <<(PICout s, const PIMathVector<Type> & v) {s << '{'; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << '}'; return s;}
|
||||
inline PICout operator <<(PICout s, const PIMathVector<Type> & v) {s << "Vector{"; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << "}"; return s;}
|
||||
|
||||
template<uint Size, typename Type>
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIMathVector<Type> & v) {s << v.c; return s;}
|
||||
template<uint Size, typename Type>
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIMathVector<Type> & v) {s >> v.c; return s;}
|
||||
|
||||
|
||||
typedef PIMathVector<int> PIMathVectori;
|
||||
typedef PIMathVector<double> PIMathVectord;
|
||||
|
||||
Reference in New Issue
Block a user