BIG deep clean
This commit is contained in:
@@ -27,23 +27,17 @@
|
||||
|
||||
template<uint Cols, uint Rows, typename Type>
|
||||
class PIMathMatrixT;
|
||||
//class PIMathVectorT;
|
||||
|
||||
|
||||
//#define PIMVCONSTR(n, t, args) PIMathVectorT<uint(n), t> _PIMathVectorConstruct(args) {PIVector<t> v; for (int i=0; i<n; ++i) v << a3; return PIMathVectorT<uint(n), t>(v)}
|
||||
|
||||
|
||||
/// Vector templated
|
||||
|
||||
#define PIMV_FOR(v, s) for (uint v = s; v < Size; ++v)
|
||||
|
||||
//#pragma pack(push, 1)
|
||||
template<uint Size, typename Type = double>
|
||||
class PIP_EXPORT PIMathVectorT {
|
||||
typedef PIMathVectorT<Size, Type> _CVector;
|
||||
public:
|
||||
PIMathVectorT() {resize();}
|
||||
//PIMathVectorT(Type val) {resize(Size); PIMV_FOR(i, 0) c[i] = val;}
|
||||
PIMathVectorT(const PIVector<Type> & val) {resize(); PIMV_FOR(i, 0) c[i] = val[i];}
|
||||
PIMathVectorT(const _CVector & st, const _CVector & fn) {resize(); set(st, fn);}
|
||||
|
||||
@@ -98,16 +92,9 @@ 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;
|
||||
// }
|
||||
|
||||
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();
|
||||
Type f = fabs(a[0]*b[1] - a[1]*b[0]) / a.length();
|
||||
return f;}
|
||||
|
||||
template<uint Size1, typename Type1> /// vector {Size, Type} to vector {Size1, Type1}
|
||||
@@ -121,7 +108,6 @@ private:
|
||||
Type c[Size];
|
||||
|
||||
};
|
||||
//#pragma pack(pop)
|
||||
|
||||
template<uint Size, typename Type>
|
||||
inline PIMathVectorT<Size, Type> operator *(const Type & x, const PIMathVectorT<Size, Type> & v) {
|
||||
@@ -142,10 +128,6 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIMathVectorT<Size, Type
|
||||
template<uint Size, typename Type>
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIMathVectorT<Size, Type> & v) {for (uint i = 0; i < Size; ++i) s >> v[i]; return s;}
|
||||
|
||||
//template<uint Size0, typename Type0 = double, uint Size1 = Size0, typename Type1 = Type0> /// vector {Size0, Type0} to vector {Size1, Type1}
|
||||
//inline operator PIMathVectorT<Size1, Type1>(const PIMathVectorT<Size0, Type0> & v) {PIMathVectorT<Size1, Type1> tv; uint sz = piMin<uint>(Size0, Size1); for (uint i = 0; i < sz; ++i) tv[i] = v[i]; return tv;}
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline PIMathVectorT<2u, T> createVectorT2(T x, T y) {return PIMathVectorT<2u, T>(PIVector<T>() << x << y);}
|
||||
template<typename T>
|
||||
@@ -230,10 +212,9 @@ public:
|
||||
_CVector operator &(const _CVector & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] *= v[i]; return tv;}
|
||||
Type operator ^(const _CVector & v) const {Type tv(0); PIMV_FOR(i, 0) tv += c[i] * v[i]; return tv;}
|
||||
|
||||
//inline operator PIMathMatrix<1, Size, Type>() {return PIMathMatrix<1, Size, Type>(c);}
|
||||
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();
|
||||
Type f = fabs(a[0]*b[1] - a[1]*b[0]) / a.length();
|
||||
return f;
|
||||
}
|
||||
|
||||
@@ -245,7 +226,6 @@ public:
|
||||
inline const Type * data() const {return c.data();}
|
||||
|
||||
private:
|
||||
// uint size_;
|
||||
PIVector<Type> c;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user