|
//计算两个点的中点坐标并返回这个点,二维
AcGePoint2d CCalculation::MiddlePoint(AcGePoint2d pt1,AcGePoint2d pt2)
{
AcGePoint2d pt;
pt.x=(pt1.x+pt2.x)/2;
pt.y=(pt1.y+pt2.y)/2;
return pt;
}
//计算两个点的中点坐标并返回这个点,三维
AcGePoint3d CCalculation::MiddlePoint(AcGePoint3d pt1,AcGePoint3d pt2)
{
AcGePoint3d pt;
pt.x=(pt1.x+pt2.x)/2;
pt.y=(pt1.y+pt2.y)/2;
pt.z=(pt1.z+pt2.z)/2;
return pt;
}
//将二维点转换成三维点
AcGePoint3d CCalculation::Pt2dTo3d(AcGePoint2d pt)
{
AcGePoint3d ptTemp(pt.x,pt.y,0);
return ptTemp;
}
//计算PI的值
double CCalculation::PI()
{
return 4 * atan(1.0);
}
//计算两个数中的最大值
double CCalculation::Max(double a,double b)
{
if (a>b) {
return a;
}else{
return b;
}
}
//计算两个数中的最小值
double CCalculation::Min(double a,double b)
{
if (a<b) {
return a;
}else{
return b;
}
}
//弧度转化为角度
double CCalculation::RtoG(double angle)
{
return angle*180/CCalculation::PI();
}
//角度转化为弧度
double CCalculation::GtoR(double angle)
{
return angle*CCalculation::PI()/180;
}
//根据一个点及角度距离计算出另外一个点的坐标
AcGePoint3d CCalculation::PolarPoint(const AcGePoint3d& pt,double angle,double distance)
{
ads_point ptForm,ptTo;
ptForm[X]=pt.x;
ptForm[Y]=pt.y;
ptForm[Z]=pt.z;
acutPolar(ptForm,angle,distance,ptTo);
return asPnt3d(ptTo);
}
//根据相对直角坐标来计算一个点的位置
AcGePoint3d CCalculation::RelativePoint(const AcGePoint3d& pt,double x,double y)
{
AcGePoint3d ptReturn(pt.x+x,pt.y+y,pt.z);
return ptReturn;
} |
|