c++数学类实现更方便的数学操作

一、功能介绍

(几何)

1.点

支持基本的数据构造和更改,以及用于显示坐标的打印函数,用于调试

另外,平面点中的Graph_Math()和Graph_EasyX()可以在EasyX绘图窗口中绘制点。

下面是一段演示

可以在数学中的标准坐标系(Math_Coordinates)中绘制P(100, 50), Q(-100, 200), A(-50, -80), B(90, -120)这4个点

#include"MyMath.h"
using namespace std;
int main()
{
    Math_Geometry::Coordinates::Math_Coordinates CC(400, 300, 20, 1);
    Math_Geometry::Point::_2D_Point P(100, 50), Q(-100, 200), A(-50, -80), B(90, -120);
    CC.IniGraph();
    CC.ShowCoordinates();
    P.Graph_Math(CC.Get_x0(), CC.Get_y0(), CC.Get_d(), CC.Get_zoom(), RED, 3, 1, 'P');
    Q.Graph_Math(CC.Get_x0(), CC.Get_y0(), CC.Get_d(), CC.Get_zoom(), BLUE, 3, 1, 'Q');
    A.Graph_Math(CC.Get_x0(), CC.Get_y0(), CC.Get_d(), CC.Get_zoom(), YELLOW, 3, 1, 'A');
    B.Graph_Math(CC.Get_x0(), CC.Get_y0(), CC.Get_d(), CC.Get_zoom(), GREEN, 3, 1, 'B');
    getch();
    return 0;
}

 

  • 数轴点
class _1D_Point//数轴点
{
	double x;
public://Set
	void SetPoint(double x);
public://Get
	double GetX() { return x; };
	double GetPoint() { return x; };
public://others
	void PrintPoint();//打印坐标
	void PrintPoint(char name);//打印坐标
	_1D_Point();
	_1D_Point(double x);
	~_1D_Point();
};
  • 平面点
class _2D_Point//平面点
{
	double x,y;
public://Set
	void SetX(double x);
	void SetY(double y);
	void SetPoint(double x, double y);
public://Get
	double GetX() { return x; };
	double GetY() { return y; };
public://others
	void Graph_EasyX(COLORREF point = WHITE, double r = 3,bool text=0,char ch='P');
	void Graph_Math(double x0,double y0 , double d, double zoom, COLORREF point = WHITE, double r = 3, bool text = 0, char ch = 'P');
	void GraphPoint(COLORREF point=WHITE);
	void PrintPoint();//打印坐标
	void PrintPoint(char name);//打印坐标
	friend _2D_Point MidPoint(_2D_Point P, _2D_Point Q);
	_2D_Point();
	_2D_Point(double x,double y);
	~_2D_Point();
};
  • 空间点
class _3D_Point//空间点
{
	double x, y, z;
public://Set
	void SetX(double x);
	void SetY(double y);
	void SetZ(double z);
	void SetPoint(double x, double y, double z);
public://Get
	double GetX() { return x; };
	double GetY() { return y; };
	double GetZ() { return z; };
public://others
	void PrintPoint();//打印坐标
	void PrintPoint(char name);//打印坐标
	_3D_Point();
	_3D_Point(double x,double y,double z);
	~_3D_Point();
};
  • 两点类 
class TwoPoint
{
	_2D_Point P1;
	_2D_Point P2;
public:
	TwoPoint();
	TwoPoint(_2D_Point P1,_2D_Point P2);
	TwoPoint(TwoPoint& other);
public:
	void SetTwoPoint(_2D_Point P1, _2D_Point P2);
	_2D_Point GetP1() { return P1; };
	_2D_Point GetP2() { return P2; };
};
  • 交点类 
class Intersection
{
	_2D_Point M;
	_2D_Point N;
public:
	Intersection();
	Intersection(_2D_Point M, _2D_Point N);
	Intersection(Intersection& other);
public:
	void SetIntersection(_2D_Point M, _2D_Point N);
	_2D_Point GetM() { return M; };
	_2D_Point GetN() { return N; };
};

  • 两点间距离
double TowPointDistant(_1D_Point, _1D_Point);//求两点间距离
double TowPointDistant(_2D_Point, _2D_Point);
double TowPointDistant(_3D_Point, _3D_Point);

2.线

  • 单直线类
typedef class _Straight_Line//直线
{
	double A, B, C;
	double k, b;
public://Set
	void SetA(double a);
	void SetB(double b);
	void SetC(double c);
	void Set_k(double k);
	void Set_b(double b);
	void ReSetLine();
	void ReSetLine(double A, double B, double C);
	void ReSetLine(double k, double b);
	void ReSetLine(Math_Geometry::Point::_2D_Point A, Math_Geometry::Point::_2D_Point B);
public://Get
	double GetA();
	double GetB();
	double GetC();
	double Get_k();
	double Get_b();
	void PrintLine();
	void Graph_EasyX(COLORREF line = WHITE, double l = 800, double w = 600, double x0 = 400, double y0 = 300);
	void Graph_Math(double x0 = 400, double y0 = 300,double d=20, double zoom=1, COLORREF line = WHITE, double l = 800, double w = 600);
	double Get_x_by_y(double y);
	double Get_y_by_x(double x);
	_2D_Point GetP_by_x(double x);
	_2D_Point GetP_by_y(double y);
public:
	_Straight_Line();
	_Straight_Line(double A, double B, double C);
	_Straight_Line(double k, double b);
	_Straight_Line(Math_Geometry::Point::_2D_Point A, Math_Geometry::Point::_2D_Point B);
	~_Straight_Line();
}_Line;
  • 双直线类
class TwoLine
{
	_Straight_Line l1;
	_Straight_Line l2;
public:
	TwoLine();
	TwoLine(_Straight_Line l1, _Straight_Line l2);
	void SetTwoLine(_Straight_Line l1, _Straight_Line l2);
	_Straight_Line Get_l1() { return l1; };
	_Straight_Line Get_l2() { return l2; };
};
  • 关系判断
//直线的关系判断
bool _StraightLine_IsVertical(_Straight_Line l1, _Straight_Line l2);//判断垂直:1->垂直 0->不垂直
bool _StraightLine_IsVarallel(_Straight_Line l1, _Straight_Line l2);//判断平行 同上
void _ShowLineRelation(_Straight_Line l1, _Straight_Line l2);//显示结果
//直线与点的关系判断
bool _StraightLine_Point_Relation(_Straight_Line AB, Math_Geometry::Point::_2D_Point P);//获取关系
void _ShowLine_Point_Relation(_Straight_Line AB, Math_Geometry::Point::_2D_Point P);//显示结果
//点到直线的距离
double _Point_Line_Distant(_Straight_Line AB, Math_Geometry::Point::_2D_Point P);//返回结果
void _Show_Point_Line_Distant(_Straight_Line AB, Math_Geometry::Point::_2D_Point P);//显示结果
//相交直线的交点坐标
_2D_Point Line_Intersection(_Straight_Line l1, _Straight_Line l2);

3.圆

同样支持绘图操作

具体功能看注释

class _Circle//圆
{
	double a, b, r;
	double D, E, F;
	double area, circumference;
public://构造函数
	_Circle();
	_Circle(double a, double b, double r);
	_Circle(_2D_Point O,double r);
	_Circle(_2D_Point A, _2D_Point B, _2D_Point C);
	_Circle(_Straight_Line l1, _Straight_Line l2, _Straight_Line l3);
	_Circle(_Circle & other);
public://Set&&Get
	//Set
	void SetCircle_abr(double a, double b, double r);
	void SetCircle_DEF(double D, double E, double F);
	void SetCircle(_2D_Point O, double r);
	void SetCircle(_2D_Point A, _2D_Point B, _2D_Point C);
	void SetCircle(_Straight_Line l1, _Straight_Line l2, _Straight_Line l3);
	//Get
	double Get_a() { return a; };
	double Get_b() { return b; };
	double Get_r() { return r; };
	double GetD() { return D; };
	double GetE() { return E; };
	double GetF() { return F; };
	double GetS() { return area; };
	double GetC() { return circumference; };
	_2D_Point GetO();
public://打印关系或属性判断
	//打印方程和属性
	void PrintCircleEquation();
	void PrintCircleNature();
	//关系判断
	int Relation_Point(_2D_Point P);//圆与点的位置关系
	void PrintRelation_Point(_2D_Point P);//打印圆与点的位置关系

	int Relation_Line(_Straight_Line AB);//圆与直线的位置关系
	void PrintRelation_Line(_Straight_Line AB);//打印圆与直线的位置关系

	int Relation_OtherCircle(_Circle C);//圆与圆的位置关系
	void PrintRelation_OtherCircle(_Circle C);//圆与圆的位置关系

	Intersection Circle_Line(_Straight_Line AB);//圆与直线的交点 返回一个交点类Intersection
	Intersection Circle_Circle(_Circle C);//圆与圆的交点 返回一个交点类Intersection

	TwoLine TangentLine(_2D_Point P);//求过圆外一点P的两条切线 返回双线类
	void PrintTangentLine(_2D_Point P);//打印切线方程

	double Chord_length(_Straight_Line AB);//弦长Chord length
	void PrintChord_length(_Straight_Line AB);//打印弦长

	_Circle About_Point_SymmetryCircle(_2D_Point M);//该圆关于点M的对称圆
	_Circle About_Line_SymmetryCircle(_Straight_Line l);//该圆关于直线l的对称圆
public://其他
	TwoPoint GetPoint_by_x(double x);//通过x获取交点 返回两点类TwoPoint
	TwoPoint GetPoint_by_y(double y);//通过y获取交点 返回两点类TwoPoint
	void Graph_EasyX();//EasyX_Coordinates下绘制当前圆
	void Graph_Math(double x0, double y0, double d, double zoom);//Math_Coordinates下绘制当前圆
	void SetStyle(COLORREF line_color = WHITE, COLORREF fill_color = WHITE, bool isFill = 0, bool isSolid = 0);//设置样式
private:
	bool isSolid;//是否有边框
	COLORREF line_color, fill_color;//线条颜色,填充颜色
	void Initial();//样式初始化
	bool isFill;//是否填充
};

4.向量

  • 平面向量

用于确定平面中的方向,支持数学中向量的加,减,向量积运算

具体功能见下方代码注释

class _2D_Vector
{
	double x, y;
public://构造函数
	_2D_Vector();
	_2D_Vector(double x, double y);
	_2D_Vector(double x1, double y1, double x2, double y2);
	_2D_Vector(_2D_Point A, _2D_Point B);
	_2D_Vector(_2D_Vector const& other);
public:
	double GetX() { return x; };
	double GetY() { return y; };
	void Information();
	void Graph_EasyX(COLORREF line = WHITE);//EasyX_Coordinates坐标系下绘制向量
	void Graph_Math(double x0, double y0, double d, double zoom, COLORREF line = WHITE);//Math_Coordinates坐标系下绘制向量
public://运算函数 运算符重载
	_2D_Vector operator+(_2D_Vector const& p1)const;
	_2D_Vector operator-(_2D_Vector const& p1)const;
	double operator*(_2D_Vector const& p1)const;
	_2D_Vector operator=(_2D_Vector const& srcPos);
public:
	bool IsVerticalWith(_2D_Vector v);//判断垂直
	bool IsVarallelWith(_2D_Vector v);//判断平行
public://角度弧度的运算
	double GetArc(_2D_Vector const P);//获取两个向量的夹角,返回弧度
	double GetAngle(_2D_Vector const P);//获取两个向量的夹角,返回角度
	double GetAngle_with_x();//获取向量与x轴的夹角的角度
	double GetModulus();//获取向量模
public:
	_2D_Vector GetUnitVector();
	void ResetVector(double x, double y);
	_2D_Vector GetVerticalVector();//获取法向量
	bool IsSpace();//判断向量是否为空
	_2D_Vector ProjectVector(_2D_Vector b);//求投影向量
	_Line GetDirectionLineby_Point(_2D_Point P);//获取与该向量同向的方向直线
	_Line GetVerticalLineby_Point(_2D_Point P);//获取与该向量垂直的直线
};
  • 射线 

 之所以将射线归纳到这里,是因为射线多了方向这一属性,而方向,我们将用向量表示

具体功能看注释

typedef class Vector_Line
{
	_2D_Point O;//端点
	_2D_Vector Dir;//方向向量
	double m, n;//向量的坐标
	double x0, y0;//源点的坐标
	double A, B, C, k, b;//射线的参数
	_Line h;
	bool Judge(_2D_Point P);//判断P点是否在射线上
	void DataProduct();//数据处理
public:
	void Graph_EasyX(COLORREF line = WHITE, double l = 1000, double w = 1000);//射线的绘制
	void Graph_Math(double x0, double y0, double d, double zoom, COLORREF line = WHITE, double l = 1000, double w = 1000);//射线的绘制
public://构造函数 数据修改获取
	Vector_Line();
	Vector_Line(_2D_Vector Dir, _2D_Point O);
	Vector_Line(Vector_Line const& other);
	_2D_Point GetO() { return O; };
	_2D_Vector GetDirection() { return Dir; };
	void ResetShootLine(_2D_Point O, _2D_Vector Dir);
public://数据处理
	_2D_Point GetP_by_x(double x);//通过x获取射线上的点
	_2D_Point GetP_by_y(double y);通过y获取射线上的点
	_2D_Point GetP_by_d(double d);//通过距O点的距离来获取P点的坐标
	void PrintShootLine();//打印射线的调试信息
}_SLine;

5.坐标系

  • EasyX坐标系

通过绘图窗口的逻辑坐标系变换而来,符合数学中的坐标系规则,仅限于绘图,在绘图窗口打印文本内容时,文字会上下镜像,不利于观看

就像这样

运行后,发现文字反了 

 

具体操作看注释 

class EasyX_Coordinates
{
	double d_origin;
	double x0, y0;//原点坐标(来自于图形界面的坐标)
	double _x0, _y0;//原点坐标(备份)无法修改
	double xasp, yasp;//缩放的倍数
	int l, w, d, zoom, zoom0;//l和w->绘图窗口的长,宽 d->是网格线的间距 zoom, zoom0坐标系缩放倍数,但zoom0为备份数据,无法更改
	void MathStd();//转化成数学中的坐标系
	void num_x(double x, double y, double value);
	void num_y(double x, double y, double value);
public://坐标系参数设置
	void SetAsp(double x, double y, double zoom = 1);//设置坐标系翻转缩放参数
	void SetOriginPoint(double x0, double y0);//设置原点坐标
public://数据的构造、修改、获取
    void Set_zoom(double zoom) { this->zoom = zoom; };
    double Get_zoom() { return zoom; };
	double Get_zoom0() { return zoom0; };
    EasyX_Coordinates();
	EasyX_Coordinates(double l, double w, double d = 20,double zoom=1, bool showCon = 0);
	EasyX_Coordinates(EasyX_Coordinates const& other);
	double Get_x0() { return x0; };
	double Get_y0() { return y0; };
	_2D_Point GetO() { _2D_Point O(_x0, _y0); return O; };
	double Get_d() { return d; };
	double Get_d_Origin() { return d_origin; };
	double Get_l() { return l; };
	double Get_w() { return w; };
	void Set_d(double d) { this->d = d; };
public://信息处理
	void ShowCoordinates();//显示坐标系
	void Example();//实例,用于参考
};
  • Math坐标系

数学坐标系不同于上述坐标系,它是通过坐标转换得到的,没有逻辑坐标系的翻转和调整,通过纯坐标转换,将数学上的坐标映射成物理坐标,实现绘图。解决绘制文字时的镜像错误

具体功能见下注释

class Math_Coordinates
{
	double x0, y0;//原点坐标(来自于图形界面的坐标)
	double x, y;
	double _x0, _y0;//原点备份
	double zoom, zoom0;//缩放的倍数
	int l, w, d;
	double d_origin;//间距备份
	int i;//记录点的个数
	void num_x(double x, double y, double value);
	void num_y(double x, double y, double value);
	void MouseControl();//鼠标控制
public://数据构造
	Math_Coordinates();
	Math_Coordinates(double x0, double y0, double d = 20, double zoom = 1);
	Math_Coordinates(Math_Coordinates const& other);
	void print(double l, double w, double d = 20, int debug = 0);//打印坐标系 d是网格线的间距
public://信息处理
	_2D_Point Switch_Physical_Coord(_2D_Point G);//转换物理坐标,即将类中的图形坐标转换为物理坐标
	_2D_Point Switch_Graphy_Coord(_2D_Point P);//转换图形坐标,将物理坐标转换成图形坐标
	void Test();//测试实例
	void ShowCoordinates();//显示坐标系
	void ShowMouseControl();//显示支持鼠标控制的坐标系
	void IniGraph(double showCon = 0);//初始化绘图窗口 showCon->是否显示控制台
	void Example();//实例
public://数据的获取和修改
	void Set_zoom(double zoom) { this->zoom = zoom; };
	double Get_zoom0() { return zoom0; };
	void SetOriginPoint(double x0, double y0);
	double Get_x0() { return x0; };
	double Get_y0() { return y0; };
	_2D_Point GetO() { _2D_Point O(_x0, _y0); return O; };
	double Get_d() { return d; };
	double Get_d_Origin() { return d_origin; };
	double Get_l() { return l; };
	double Get_w() { return w; };
	void Set_d(double d) { this->d = d; };
	double Get_zoom() { return zoom; };
};

6.矩形  

	class MyRectangle
	{
		double left, right, up, down;
		double lenght, wide, e;//e为矩比 长与宽的比值
		_2D_Point lu_A, ru_B, rd_C, ld_D;//四个顶点
		_2D_Point O;//对称中心
		double C, S;//周长和面积
		_2D_Point RevolvePoint(_2D_Point M, _2D_Point P, double angle);//点的旋转
		void Line(_2D_Point A, _2D_Point B);//绘制直线
	private://style
		bool isSolid;//有无边框
		COLORREF line_color, fill_color;//边框颜色、填充颜色
		void Initial();//样式初始化
		bool isSoft;//是否为软角矩形
		bool isFill;//是否填充
		double s;//软角程度 s=1时为矩形的内切椭圆
		void fillRrectangle();
	public://构造函数
		MyRectangle();
		MyRectangle(double left, double up, double right, double down);
		MyRectangle(_2D_Point lu_A, _2D_Point rd_C);
		MyRectangle(_2D_Point O, double lenght, double wide);
		MyRectangle(double r, _2D_Point O, double e);//r->外接球半径;e->矩比
		MyRectangle(double r, double angle, _2D_Point O);//angle为对角线夹角
		MyRectangle(MyRectangle const& other);
	public://Get
		double Get_left() { return left; };
		double Get_up() { return up; };
		double Get_right() { return right; };
		double Get_down() { return down; };
		double Get_S() { return S; };
		double Get_C() { return C; };
		double Get_length() { return lenght; };
		double Get_wide() { return wide; };
		double Get_e() { return e; };
		_2D_Point Get_luA() { return lu_A; };
		_2D_Point Get_ldD() { return ld_D; };
		_2D_Point Get_ruB() { return ru_B; };
		_2D_Point Get_rdC() { return rd_C; };
		_2D_Point GetO() { return O; };
	public://Set
		void ResetMyRectangle(double left, double up, double right, double down);//s表示软化程度
		void ResetMyRectangle(_2D_Point lu_A, _2D_Point rd_C);
		void ResetMyRectangle(_2D_Point O, double lenght, double wide);
		void ResetMyRectangle(double r, _2D_Point O, double e);//r->外接球半径;e->矩比
		void ResetMyRectangle(double r, double angle, _2D_Point O);//angle为对角线夹角
	public://矩形的显示
		void Information();//矩形调试信息
		void Graph_EasyX();//在EasyX_Coordinates下绘制无旋转变化的矩形
		void GraphR_EasyX();//在EasyX_Coordinates下绘制旋转变化后的矩形
		void Graph_Math(double x0,double y0, double d, double zoom);//在Math_Coordinates下绘制无旋转变化的矩形
		void GraphR_Math(double x0, double y0, double d, double zoom);//在Math_Coordinates下绘制旋转变化后的矩形
		void SetStyle(COLORREF line_color=WHITE, COLORREF fill_color=WHITE,bool isSolid=0, bool isSoft=0, bool isFill=0,double s=2);//设置样式
	public://变换及判断
		void Zoom(double z);//缩放程度
		void Revolve(double angle);//旋转 direction 1->顺时针 2->逆时针
		void Move(double x, double y);//平移 x0,y0 分别表示水平和竖直方向的移动量
		bool IsInMyRectangle_Mouse(_2D_Point P, double x0, double y0, double d, double zoom);//判断点是否在矩形内,用于矩形按钮中鼠标点击范围的判断
		bool IsInMyRectangle_Mouse(double x,double y, double x0, double y0, double d, double zoom);//重载
		bool IsInMyRectangle(_2D_Point P);
		bool IsInMyRectangle(double x, double y);//重载
	public://直线
		_Straight_Line GetLine_AB();
		_Straight_Line GetLine_BC();
		_Straight_Line GetLine_CD();
		_Straight_Line GetLine_AD();
		_Straight_Line GetLine_AC();
		_Straight_Line GetLine_BD();
		_Straight_Line GetLine_Ox();
		_Straight_Line GetLine_Oy();
	}; 
}

(代数)

1.方程

  • 一元二次方程
typedef class One_Dimensional_Second_Equation //Dimensional 维
{
	double a, b, c;
	double x1, x2;
public:
	One_Dimensional_Second_Equation();
	One_Dimensional_Second_Equation(double a, double b, double c);
	void Set_abc(double a, double b, double c);
	void PrintRoots();
	double Get_x1() { return x1; };
	double Get_x2() { return x2; };
}OneS;
  • 二元一次方程
typedef class Two_Dimensional_First_Equation
{
	double a, b, c;
	double d, e, f;
	double x, y;
public:
	void Set_abc(double a, double b, double c);
	void Set_def(double d, double e, double f);
	void Calculate();//解方程计算 Get_x() Get_y()前调用
	void PrintRoots();
	double Get_x() { return x; };
	double Get_y() { return y; };
}TwoF;
  • 三元一次方程
typedef class Three_Dimensional_First_Equation
{
	double a, b, c, d;
	double e, f, g, h;
	double i, j, k, l;
	double x, y, z;
public:
	void Set_abcd(double a, double b, double c, double d);
	void Set_efgh(double e, double f, double g, double h);
	void Set_ijkl(double i, double j, double k, double l);
	void Calculate();//在获取x,y,z值之前调用
	void PrintRoots();
	double Get_x() { return x; };
	double Get_y() { return y; };
	double Get_z() { return z; };
}ThreeF;

2.数

  • 分数
typedef class MarkNum//分数
{
	int base;//分母
	int sub;//分子
public://构造函数
	MarkNum(int base,int sub);
	MarkNum();
	MarkNum(MarkNum const& other);
	void ShowNum();
	void Simplify();//分数化简
	void ResetNum(int base, int sub);
	int GetBase() { return base; };
	int GetSub() { return sub; };
	double GetValue() { return (double)sub / (double)base; }
public://运算符重载
	MarkNum& operator+(const MarkNum& p)const;
	MarkNum& operator-(const MarkNum& p)const;
	MarkNum& operator*(const MarkNum& p)const;
	MarkNum& operator/(const MarkNum& p)const;
	MarkNum& operator=(const MarkNum& p);
	MarkNum& operator=(const double p);
}Mark;

二、源代码 

MyMath.h(头文件)

#pragma once
#define Pi 3.1415926535897
#include<vector>
#include<conio.h>
#include <stdio.h>
#include <math.h>
#include <iostream>
#include<easyx.h>
#include <graphics.h>
using namespace std;
//几何
namespace Math_Geometry
{
	//点
	namespace Point
	{
		class _1D_Point//数轴点
		{
			double x;
		public://Set
			void SetPoint(double x);
		public://Get
			double GetX() { return x; };
			double GetPoint() { return x; };
		public://others
			void PrintPoint();//打印坐标
			void PrintPoint(char name);//打印坐标
			_1D_Point();
			_1D_Point(double x);
			~_1D_Point();
		};

		class _2D_Point//平面点
		{
			double x,y;
		public://Set
			void SetX(double x);
			void SetY(double y);
			void SetPoint(double x, double y);
		public://Get
			double GetX() { return x; };
			double GetY() { return y; };
		public://others
			void Graph_EasyX(COLORREF point = WHITE, double r = 3,bool text=0,char ch='P');
			void Graph_Math(double x0,double y0 , double d, double zoom, COLORREF point = WHITE, double r = 3, bool text = 0, char ch = 'P');
			void GraphPoint(COLORREF point=WHITE);
			void PrintPoint();//打印坐标
			void PrintPoint(char name);//打印坐标
			friend _2D_Point MidPoint(_2D_Point P, _2D_Point Q);
			_2D_Point();
			_2D_Point(double x,double y);
			~_2D_Point();
		};

		class _3D_Point//空间点
		{
			double x, y, z;
		public://Set
			void SetX(double x);
			void SetY(double y);
			void SetZ(double z);
			void SetPoint(double x, double y, double z);
		public://Get
			double GetX() { return x; };
			double GetY() { return y; };
			double GetZ() { return z; };
		public://others
			void PrintPoint();//打印坐标
			void PrintPoint(char name);//打印坐标
			_3D_Point();
			_3D_Point(double x,double y,double z);
			~_3D_Point();
		};
		
		class TwoPoint
		{
			_2D_Point P1;
			_2D_Point P2;
		public:
			TwoPoint();
			TwoPoint(_2D_Point P1,_2D_Point P2);
			TwoPoint(TwoPoint& other);
		public:
			void SetTwoPoint(_2D_Point P1, _2D_Point P2);
			_2D_Point GetP1() { return P1; };
			_2D_Point GetP2() { return P2; };
		};

		class Intersection
		{
			_2D_Point M;
			_2D_Point N;
		public:
			Intersection();
			Intersection(_2D_Point M, _2D_Point N);
			Intersection(Intersection& other);
		public:
			void SetIntersection(_2D_Point M, _2D_Point N);
			_2D_Point GetM() { return M; };
			_2D_Point GetN() { return N; };
		};

		double TowPointDistant(_1D_Point, _1D_Point);//求两点间距离
		double TowPointDistant(_2D_Point, _2D_Point);
		double TowPointDistant(_3D_Point, _3D_Point);
	}
	//直线
	namespace Line
	{
		using namespace Math_Geometry::Point;
		void Line(_2D_Point A, _2D_Point B);
		typedef class _Straight_Line//直线
		{
			double A, B, C;
			double k, b;
		public://Set
			void SetA(double a);
			void SetB(double b);
			void SetC(double c);
			void Set_k(double k);
			void Set_b(double b);
			void ReSetLine();
			void ReSetLine(double A, double B, double C);
			void ReSetLine(double k, double b);
			void ReSetLine(Math_Geometry::Point::_2D_Point A, Math_Geometry::Point::_2D_Point B);
		public://Get
			double GetA();
			double GetB();
			double GetC();
			double Get_k();
			double Get_b();
			void PrintLine();
			void Graph_EasyX(COLORREF line = WHITE, double l = 800, double w = 600, double x0 = 400, double y0 = 300);
			void Graph_Math(double x0 = 400, double y0 = 300,double d=20, double zoom=1, COLORREF line = WHITE, double l = 800, double w = 600);
			double Get_x_by_y(double y);
			double Get_y_by_x(double x);
			_2D_Point GetP_by_x(double x);
			_2D_Point GetP_by_y(double y);
		public:
			_Straight_Line();
			_Straight_Line(double A, double B, double C);
			_Straight_Line(double k, double b);
			_Straight_Line(Math_Geometry::Point::_2D_Point A, Math_Geometry::Point::_2D_Point B);
			~_Straight_Line();
		}_Line;

		class TwoLine
		{
			_Straight_Line l1;
			_Straight_Line l2;
		public:
			TwoLine();
			TwoLine(_Straight_Line l1, _Straight_Line l2);
			void SetTwoLine(_Straight_Line l1, _Straight_Line l2);
			_Straight_Line Get_l1() { return l1; };
			_Straight_Line Get_l2() { return l2; };
		};

		//直线的关系判断
		bool _StraightLine_IsVertical(_Straight_Line l1, _Straight_Line l2);//判断垂直:1->垂直 0->不垂直
		bool _StraightLine_IsVarallel(_Straight_Line l1, _Straight_Line l2);//判断平行 同上
		void _ShowLineRelation(_Straight_Line l1, _Straight_Line l2);//显示结果
		//直线与点的关系判断
		bool _StraightLine_Point_Relation(_Straight_Line AB, Math_Geometry::Point::_2D_Point P);//获取关系
		void _ShowLine_Point_Relation(_Straight_Line AB, Math_Geometry::Point::_2D_Point P);//显示结果
		//点到直线的距离
		double _Point_Line_Distant(_Stra
  • 26
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值