#pragma once #ifndef CPOINT3_H #define CPOINT3_H #include #include "afxdisp.h" //#define CPOINT3_DEBUG_CHECKS #ifdef CPOINT3_DEBUG_CHECKS #include #endif //#pragma warning (disable:4270) // we don't care about non-const initializers, as we do use them class CPoint3: public CObject { public: CPoint3(void); // default object CPoint3(const CPoint3& t); // copy constructors CPoint3(const double* t); // Conversion from array CPoint3(const double x, const double y, const double z); CPoint3(const float* pts); // Conversoin from array of floats ~CPoint3(void); operator const double *(void) const; // subscript operator and operator double *(void); // subscript operator and // conversion to array/pointer friend CPoint3 operator* (const CPoint3 &t, double mult); // scalar multiply friend CPoint3 operator* (double mult, const CPoint3 &t); // scalar multiply friend CPoint3 operator+(const CPoint3 &t, double offset); // add offset pointwise friend CPoint3 operator+(double offset, const CPoint3 &t); // add offset pointwise friend CPoint3 operator-(const CPoint3 &t, double offset); // subtract offset pointwise friend CPoint3 operator-(double offset, const CPoint3 &t); // subtract offset pointwise CPoint3& operator*=(double mult); // scalar multiply and assignment CPoint3& operator*=(const CPoint3 &t); // point wise multiplication and assignment friend CPoint3 operator/(const CPoint3 &, double divisor); // scalar divide CPoint3& operator/=(const CPoint3 &t); // point wise divide and assignment CPoint3& operator/=(double divisor); // scalar divide and assignment friend double operator* (const CPoint3 &t, const CPoint3 &u); // dot product friend CPoint3 operator+(const CPoint3 &t, const CPoint3 &u); // pointwise addition CPoint3& operator+=(const CPoint3 &t); // pointwise addition and assignment CPoint3& operator+=(const double* t); CPoint3& operator+=(double offset); // add offset pointwise friend CPoint3 operator-(const CPoint3 &t, const CPoint3 &u); // pointwise subtraction CPoint3 operator-(void); // additive inverse CPoint3& operator-=(const CPoint3 &t); // pointwise subtraction and assignment friend void operator << (CArchive &InArch , CPoint3 & InPnt); // write a CPoint3 friend void operator >>(CArchive &InArch , CPoint3 & InPnt); // read a CPoin3 CPoint3& operator-=(const double* t); CPoint3& operator-=(double offset); // subtract offset pointwise. CPoint3& operator=(const CPoint3& t); // assignment Needed a const operator for use // with CArray - TJ CPoint3& operator=(const double* t); // assignment CPoint3& operator=(const double t); // assignment CPoint3& operator=(const float* t); bool operator==(const CPoint3 &t) const; // test for equality bool operator!=(const CPoint3 &t) const; // test for inequality void display(void); // debugging function void Serialize(CArchive & archive); // the ubiquitous function for IO double norm(void) const; // return the norm of this object double norm2(void) const; // return the squared norm of this object double normalize(void); // normalize and return old norm. double Normalize(double dbEpsilon); CPoint3 crossOnly(const CPoint3 &u) const; // cross, but do not normalize. CPoint3 cross(const CPoint3 &u) const; // cross product m_data x v normalized. CPoint3 cross2(const CPoint3 &u) const; // cross product m_data x v normalized and can be (0, 0, 0) double maxabs(int* Index = NULL) const; // return the value of the largest absulute double minabs(int* Index = NULL) const; // return the value of the smallest absulute void setXYZ(double x, double y, double z); double angleBetween(const CPoint3 &inPoint); CPoint3 constructOrthogonalVector(void); // value coordinate friend double distance(const CPoint3 &t, const CPoint3 &u) { return ((t - u).norm()); } #ifdef CPOINT3_DEBUG_CHECKS bool IsValid(void) const { if(this) return (_finite(m_data[0]) && _finite(m_data[1]) && _finite(m_data[2])); return false; } #endif BOOL toVARIANT(VARIANT *pv); BOOL fromVARIANT(VARIANT pv); double x; double y; double z; }; #endif