⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dyx_point.h

📁 这里提供一套C++的point定义类,里面有丰富的成员函数,全部通过验证。同时也望朋友们对其进行扩充和改进
💻 H
字号:
#if !defined(_DYX_Point_H_)
#define _DYX_Point_H_


#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


class LineSeg2D;
class Line2D;
class Circle2D;
class MyRectangle;

//------------------------------
// To declare the class Point2D 
//------------------------------
class Point2D
{
public:
	double x;
	double y;
public:
	Point2D(const double x1=0.0, const double y1=0.0)
	{
		x = x1;
		y = y1;
	}
	Point2D(const Point2D &P)
	{
		x = P.x;
		y = P.y;
	}
	Point2D(const double Pt[2])
	{
		x = Pt[0];
		y = Pt[1];
	}
	~Point2D()
	{
	}

	void operator=(const Point2D &P);
	BOOL operator==(const Point2D &P) const;
	BOOL operator!=(const Point2D &P) const;
	Point2D operator+(const Point2D &P) const;
	Point2D operator-(const Point2D &P) const;
	
	void SetPoint(const double x1, const double y1);
	void SetPoint(const double Pt[2]);
	void SetPoint(const Point2D Pt);

	double Multiply(const Point2D &P, const Point2D &Q) const;
	double dotMultiply(const Point2D &P, const Point2D &Q) const;

	void Move(const double x1, const double y1);
	double Distance(const Point2D &P) const;
	double Distance(const LineSeg2D &L) const;

	void Rotate(const Point2D &RotateCenter, const double dAngle);
	BOOL IsEqualTo(const Point2D &P, const double Tol) const;
	BOOL OnLineSeg(const LineSeg2D &L) const;
	double Angle(const Point2D &B) const;
	double Angle(const Point2D &B, const Point2D &C) const;
	double TriangleAngle(const Point2D &B, const Point2D &C) const;
	double TriangleArea(const Point2D &B, const Point2D &C) const;

	double Relation(const LineSeg2D &L) const;
	Point2D Perpendicular(const LineSeg2D &L) const;
	double NearestDistance(const LineSeg2D &L, Point2D &P) const;
	void TangentialPoint(const Circle2D &Cir, Point2D &P1, Point2D &P2) const;
	Point2D Symmetry(const Line2D &L) const;

	BOOL Inside(const Circle2D &Cir) const;
	BOOL Inside(const MyRectangle &Rect, const double dGap=0.0) const;
};


//------------------------------
// To declare the class Point3D 
//------------------------------
class Point3D : public Point2D
{
public:
	double z;
public:
	Point3D(const double x1=0.0, const double y1=0.0, const double z1=0.0) : Point2D(x1, y1)
	{
		z = z1;
	}
	Point3D(const Point3D &P) : Point2D(P.x, P.y)
	{
		z = P.z;
	}
	Point3D(const double Pt[3]) : Point2D(Pt[0], Pt[1])
	{
		z = Pt[2];
	}
	~Point3D()
	{
	}

	void operator=(const Point3D &P);
	BOOL operator==(const Point3D &P) const;
	BOOL operator!=(const Point3D &P) const;
	Point3D operator+(const Point3D &P) const;
	Point3D operator-(const Point3D &P) const;

	void SetPoint(const double x1, const double y1, const double z1);
	void SetPoint(const double Pt[3]);

	double Distance(const Point3D &P) const;
};

void MyTest(void);

#endif  //_DYX_Point_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -