|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
//<2F>ļ<EFBFBD> Point2D.h
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
#ifndef AFX_EXT_CLASS
|
|
|
|
|
|
#define AFX_EXT_CLASS Q_DECL_IMPORT
|
|
|
|
|
|
#endif
|
|
|
|
|
|
#include "math.h"
|
|
|
|
|
|
#include "../TBase/TList.h"
|
|
|
|
|
|
#include "../TBase/TTypeArray.h"
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _QT_VERSION
|
|
|
|
|
|
#include "QGBase/dfarchive.h"
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define ZERO 1e-10
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _QT_VERSION
|
|
|
|
|
|
//#include <QPoint>
|
|
|
|
|
|
#include "qsize.h"
|
|
|
|
|
|
#include "qrect.h"
|
|
|
|
|
|
#include "QGBase/DFSize.h"
|
|
|
|
|
|
#include "QGBase/DF_POINT.h"
|
|
|
|
|
|
#include "QGBase/DF_Rect.h"
|
|
|
|
|
|
typedef DF_Rect CRect;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace GBase
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
class CSize8;
|
|
|
|
|
|
class dfPoint;
|
|
|
|
|
|
class CPoint3D;
|
|
|
|
|
|
|
|
|
|
|
|
class AFX_EXT_CLASS CPoint2D
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
CPoint2D(double xx, double yy);
|
|
|
|
|
|
CPoint2D(const CPoint2D& pt);
|
|
|
|
|
|
CPoint2D(const CSize8& st);
|
|
|
|
|
|
CPoint2D(void);
|
|
|
|
|
|
virtual ~CPoint2D(void);
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
double x0, y0;
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
CPoint2D operator +(const CPoint2D &point);
|
|
|
|
|
|
CPoint2D operator /(const CPoint2D &point);
|
|
|
|
|
|
void operator =(const CPoint2D &point);
|
|
|
|
|
|
void operator =(const dfPoint &point);
|
|
|
|
|
|
void operator =(const CPoint &point);
|
|
|
|
|
|
void operator =(const CSize8 &sz);
|
|
|
|
|
|
BOOL operator==(const CPoint2D &point);
|
|
|
|
|
|
BOOL operator==(const CPoint2D &point) const;
|
|
|
|
|
|
void operator +=(const CPoint2D& point);
|
|
|
|
|
|
void operator -=(const CPoint2D& point);
|
|
|
|
|
|
void operator *=(const CPoint2D& point);
|
|
|
|
|
|
void operator /=(const CPoint2D& point);
|
|
|
|
|
|
void operator +=(const double dist);
|
|
|
|
|
|
void operator -=(const double dist);
|
|
|
|
|
|
void operator *=(const double factor);
|
|
|
|
|
|
void operator /=(const double den);
|
|
|
|
|
|
bool operator <(const CPoint2D& point) const; //<2F><><EFBFBD><EFBFBD>С<EFBFBD><D0A1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
virtual void OffsetPt(double dx, double dy);
|
|
|
|
|
|
virtual void ScaleCoorPt(double xs, double ys, double dx, double dy);
|
|
|
|
|
|
virtual void RotatePt(double xs, double ys, double angle);
|
|
|
|
|
|
void SetPoint(double xx, double yy);
|
|
|
|
|
|
void RotatePt(double angle);
|
|
|
|
|
|
double Distance(const CPoint2D& pt) const;
|
|
|
|
|
|
|
|
|
|
|
|
double Dot(const CPoint2D& pt) const;
|
|
|
|
|
|
CPoint2D Normalize() const;
|
|
|
|
|
|
|
|
|
|
|
|
virtual double Abs() const; //xyƽ<79><C6BD><EFBFBD>͵ĸ<CDB5>
|
|
|
|
|
|
virtual double squareAbs() const; //xyƽ<79><C6BD><EFBFBD><EFBFBD>
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class AFX_EXT_CLASS CSize8
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
CSize8(void);
|
|
|
|
|
|
CSize8(double sx, double sy);
|
|
|
|
|
|
CSize8(const CSize8& sz);
|
|
|
|
|
|
CSize8(const CPoint2D& point);
|
|
|
|
|
|
virtual ~CSize8(void);
|
|
|
|
|
|
|
|
|
|
|
|
virtual void Serialize(CArchive& ar);
|
|
|
|
|
|
|
|
|
|
|
|
void operator=(const CSize8& sz);
|
|
|
|
|
|
void operator=(const CSize& sz);
|
|
|
|
|
|
void operator=(const CPoint2D& point);
|
|
|
|
|
|
BOOL operator==(const CSize8& sz);
|
|
|
|
|
|
void operator +=(const CSize8& sz);
|
|
|
|
|
|
void operator -=(const CSize8& sz);
|
|
|
|
|
|
void operator +=(const double sz);
|
|
|
|
|
|
void operator -=(const double sz);
|
|
|
|
|
|
void SetSize(double sx, double sy);
|
|
|
|
|
|
void ScaleSize(double sx, double sy);
|
|
|
|
|
|
void Rotate(double angle);
|
|
|
|
|
|
|
|
|
|
|
|
double cx;
|
|
|
|
|
|
double cy;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define AXIS_X 1
|
|
|
|
|
|
#define AXIS_Y 2
|
|
|
|
|
|
#define AXIS_Z 3
|
|
|
|
|
|
|
|
|
|
|
|
class AFX_EXT_CLASS CPoint3D : public CPoint2D
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
CPoint3D(void);
|
|
|
|
|
|
CPoint3D(double x, double y, double z);
|
|
|
|
|
|
virtual ~CPoint3D(void);
|
|
|
|
|
|
|
|
|
|
|
|
double z0;
|
|
|
|
|
|
|
|
|
|
|
|
void Create(double x, double y, double z);
|
|
|
|
|
|
virtual void SetPoint(double x, double y, double z);
|
|
|
|
|
|
|
|
|
|
|
|
//0=x, 1=y, 2=z
|
|
|
|
|
|
virtual double& operator[](int idx) { return idx != 0 ? (idx == 1 ? y0 : z0) : x0; }
|
|
|
|
|
|
virtual double operator[](int idx) const { return idx != 0 ? (idx == 1 ? y0 : z0) : x0; }
|
|
|
|
|
|
CPoint3D operator+(const CPoint3D&) const;
|
|
|
|
|
|
CPoint3D operator-(const CPoint3D&) const;
|
|
|
|
|
|
CPoint3D operator*(double) const;
|
|
|
|
|
|
CPoint3D operator/(double) const;
|
|
|
|
|
|
void operator=(const CPoint3D& t);
|
|
|
|
|
|
void operator=(const CPoint2D& t);
|
|
|
|
|
|
void operator+=(const CPoint3D& t);
|
|
|
|
|
|
void operator-=(const CPoint3D& t);
|
|
|
|
|
|
void operator/=(const CPoint3D& t);
|
|
|
|
|
|
void operator*=(const CPoint3D& t);
|
|
|
|
|
|
void operator*=(double ds);
|
|
|
|
|
|
double Distance2(CPoint3D& other);
|
|
|
|
|
|
double Distance(CPoint3D& other);
|
|
|
|
|
|
|
|
|
|
|
|
void RotatePt(double angle, int nRotateAxis);
|
|
|
|
|
|
void RotatePt(double cosa, double sina, int nRotateAxis);
|
|
|
|
|
|
void RotatePt(double xm, double ym, double zm, double angle, int nRotateAxis);
|
|
|
|
|
|
|
|
|
|
|
|
CPoint3D Cross(const CPoint3D& b) const;
|
|
|
|
|
|
CPoint3D Normalize() const;
|
|
|
|
|
|
double Dot(const CPoint3D& b) const;
|
|
|
|
|
|
|
|
|
|
|
|
virtual double Abs() const;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class AFX_EXT_CLASS CSize3D : public CSize8
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
CSize3D(void);
|
|
|
|
|
|
CSize3D(double sx, double sy, double sz);
|
|
|
|
|
|
CSize3D(const CSize3D& sz);
|
|
|
|
|
|
CSize3D(const CPoint3D& point);
|
|
|
|
|
|
virtual ~CSize3D(void);
|
|
|
|
|
|
|
|
|
|
|
|
virtual void Serialize(CArchive& ar);
|
|
|
|
|
|
|
|
|
|
|
|
//0=x, 1=y, 2=z
|
|
|
|
|
|
virtual double& operator[](int idx) { return idx != 0 ? (idx == 1 ? cy : cz) : cx; }
|
|
|
|
|
|
virtual double operator[](int idx) const { return idx != 0 ? (idx == 1 ? cy : cz) : cx; }
|
|
|
|
|
|
void operator=(const CSize3D& sz);
|
|
|
|
|
|
void operator=(const CPoint3D& point);
|
|
|
|
|
|
BOOL operator==(const CSize3D& sz);
|
|
|
|
|
|
void operator +=(const CSize3D& sz);
|
|
|
|
|
|
void operator -=(const CSize3D& sz);
|
|
|
|
|
|
void operator +=(const double sz);
|
|
|
|
|
|
void operator -=(const double sz);
|
|
|
|
|
|
void SetSize(double sx, double sy, double sz);
|
|
|
|
|
|
void ScaleSize(double sx, double sy, double sz);
|
|
|
|
|
|
|
|
|
|
|
|
double cz;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AFX_EXT_CLASS CRect3D
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
CRect3D(void);
|
|
|
|
|
|
~CRect3D(void);
|
|
|
|
|
|
|
|
|
|
|
|
void SetRect(CPoint3D ptMin, CPoint3D ptMax);
|
|
|
|
|
|
CPoint3D CenterPoint(void);
|
|
|
|
|
|
void NormalizeRect(void);
|
|
|
|
|
|
|
|
|
|
|
|
CSize3D GetSize();
|
|
|
|
|
|
double Width(void); //dx
|
|
|
|
|
|
double Height(void); //dy
|
|
|
|
|
|
double Depth(void); //dz
|
|
|
|
|
|
|
|
|
|
|
|
void InflateRect(double x, double y, double z);
|
|
|
|
|
|
void DeflateRect(double x, double y, double z);
|
|
|
|
|
|
|
|
|
|
|
|
CPoint3D m_ptMin;
|
|
|
|
|
|
CPoint3D m_ptMax;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class AFX_EXT_CLASS CPoint4D : public CPoint3D
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
CPoint4D(void);
|
|
|
|
|
|
CPoint4D(double xx0, double yy0, double zz0, double ll0);
|
|
|
|
|
|
virtual ~CPoint4D(void);
|
|
|
|
|
|
|
|
|
|
|
|
virtual void SetPoint(double xx0, double yy0, double zz0, double ll0);
|
|
|
|
|
|
virtual double& operator[](int idx);
|
|
|
|
|
|
virtual double operator[](int idx) const;
|
|
|
|
|
|
|
|
|
|
|
|
CPoint4D& operator = (const CPoint4D& p);
|
|
|
|
|
|
BOOL operator == (const CPoint4D& p);
|
|
|
|
|
|
BOOL operator == (const CPoint4D& p) const;
|
|
|
|
|
|
BOOL operator != (const CPoint4D& p);
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
double l0;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AFX_EXT_CLASS dfPoint : public CPoint4D
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
dfPoint(void);
|
|
|
|
|
|
|
|
|
|
|
|
void SetPoint(double x, double y, double z);
|
|
|
|
|
|
void SetPoint(double xx0, double yy0, double zz0, double ll0);
|
|
|
|
|
|
|
|
|
|
|
|
dfPoint& operator = (const dfPoint& p);
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
int no;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef TList<dfPoint> CPointList;
|
|
|
|
|
|
typedef TTypeArray<dfPoint> CPointArr;
|
|
|
|
|
|
typedef TTypeArray<CPoint2D> CPoint2DArray;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CPoint2D::OffsetPt(double dx, double dy)
|
|
|
|
|
|
{
|
|
|
|
|
|
x0 += dx;
|
|
|
|
|
|
y0 += dy;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE CPoint2D CPoint2D::operator +(const CPoint2D &point)
|
|
|
|
|
|
{
|
|
|
|
|
|
return CPoint2D(x0 + point.x0, y0 + point.y0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE CPoint2D CPoint2D::operator /(const CPoint2D &point)
|
|
|
|
|
|
{
|
|
|
|
|
|
return CPoint2D(x0 / point.x0, y0 / point.y0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CPoint2D::operator =(const CPoint2D &point)
|
|
|
|
|
|
{
|
|
|
|
|
|
x0 = point.x0;
|
|
|
|
|
|
y0 = point.y0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CPoint2D::operator =(const dfPoint &point)
|
|
|
|
|
|
{
|
|
|
|
|
|
x0 = point.x0;
|
|
|
|
|
|
y0 = point.y0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CPoint2D::operator =(const CPoint &point)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
x0 = point.x;
|
|
|
|
|
|
y0 = point.y;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CPoint2D::operator =(const CSize8 &sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
x0 = sz.cx;
|
|
|
|
|
|
y0 = sz.cy;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CPoint2D::SetPoint(double xx, double yy)
|
|
|
|
|
|
{
|
|
|
|
|
|
x0 = xx;
|
|
|
|
|
|
y0 = yy;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE BOOL CPoint2D::operator==(const CPoint2D& point)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (fabs(x0 - point.x0) < ZERO && fabs(y0 - point.y0) < ZERO) return TRUE;
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE BOOL CPoint2D::operator==(const CPoint2D& point) const
|
|
|
|
|
|
{
|
|
|
|
|
|
if (fabs(x0 - point.x0) < ZERO && fabs(y0 - point.y0) < ZERO) return TRUE;
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
}
|
|
|
|
|
|
AFX_INLINE bool CPoint2D::operator <(const CPoint2D& point) const //<2F><><EFBFBD><EFBFBD>С<EFBFBD><D0A1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (x0 < point.x0)
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
if (fabs(x0 - point.x0) < ZERO && y0 < point.y0)
|
|
|
|
|
|
return true;
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CSize8::SetSize(double sx, double sy)
|
|
|
|
|
|
{
|
|
|
|
|
|
cx = sx;
|
|
|
|
|
|
cy = sy;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CSize8::operator=(const CSize8& sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
cx = sz.cx;
|
|
|
|
|
|
cy = sz.cy;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CSize8::operator=(const CPoint2D& point)
|
|
|
|
|
|
{
|
|
|
|
|
|
cx = point.x0;
|
|
|
|
|
|
cy = point.y0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CSize8::operator=(const CSize& sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
cx = sz.cx;
|
|
|
|
|
|
cy = sz.cy;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE BOOL CSize8::operator==(const CSize8& sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (fabs(cx - sz.cx) < ZERO && fabs(cy - sz.cy) < ZERO) return TRUE;
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CSize8::operator +=(const CSize8& sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
cx += sz.cx;
|
|
|
|
|
|
cy += sz.cy;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CSize8::operator -=(const CSize8& sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
cx -= sz.cx;
|
|
|
|
|
|
cy -= sz.cy;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CSize8::operator +=(const double sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
cx += sz;
|
|
|
|
|
|
cy += sz;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CSize8::operator -=(const double sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
cx -= sz;
|
|
|
|
|
|
cy -= sz;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
|
//CSize3D
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CSize3D::SetSize(double sx, double sy, double sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
cx = sx;
|
|
|
|
|
|
cy = sy;
|
|
|
|
|
|
cz = sz;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CSize3D::operator=(const CSize3D& sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
cx = sz.cx;
|
|
|
|
|
|
cy = sz.cy;
|
|
|
|
|
|
cz = sz.cz;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CSize3D::operator=(const CPoint3D& point)
|
|
|
|
|
|
{
|
|
|
|
|
|
cx = point.x0;
|
|
|
|
|
|
cy = point.y0;
|
|
|
|
|
|
cz = point.z0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE BOOL CSize3D::operator==(const CSize3D& sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (fabs(cx - sz.cx) < ZERO &&
|
|
|
|
|
|
fabs(cy - sz.cy) < ZERO &&
|
|
|
|
|
|
fabs(cz - sz.cz) < ZERO)
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CSize3D::operator +=(const CSize3D& sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
cx += sz.cx;
|
|
|
|
|
|
cy += sz.cy;
|
|
|
|
|
|
cz += sz.cz;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CSize3D::operator -=(const CSize3D& sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
cx -= sz.cx;
|
|
|
|
|
|
cy -= sz.cy;
|
|
|
|
|
|
cz -= sz.cz;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CSize3D::operator +=(const double sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
cx += sz;
|
|
|
|
|
|
cy += sz;
|
|
|
|
|
|
cz += sz;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AFX_INLINE void CSize3D::operator -=(const double sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
cx -= sz;
|
|
|
|
|
|
cy -= sz;
|
|
|
|
|
|
cz -= sz;
|
|
|
|
|
|
}
|
|
|
|
|
|
};//namespace
|
|
|
|
|
|
|
|
|
|
|
|
using namespace GBase;
|