首页 > 编程知识 正文

OpenCasCade数学库 点gpPnt,math库中的数学函数

时间:2023-05-03 14:41:07 阅读:229191 作者:2419

 gp_Pnt描述了三维空间中的一个

 gp_Pnt的定义:

class gp_Pnt{public: ...private: gp_XYZ coord;};

默认情况下,位置为原点。

inline gp_Pnt::gp_Pnt() { }

两点的重心。计算公式为:(Alpha*this + Beta*P) / (Alpha + Beta)

inline void gp_Pnt::BaryCenter(const Standard_Real A,const gp_Pnt& P,const Standard_Real B){ coord.SetLinearForm(A,coord,B,P.coord); coord.Divide(A + B);}

两个点是否相等的判断:两点间距小于等于容差。

inline Standard_Boolean gp_Pnt::IsEqual(const gp_Pnt& Other,const Standard_Real LinearTolerance) const{ return Distance (Other) <= LinearTolerance; }

点关于点的对称变换。

void gp_Pnt::Mirror (const gp_Pnt& P){ coord.Reverse (); gp_XYZ XYZ = P.coord; XYZ.Multiply (2.0); coord.Add (XYZ);}

点关于轴的对称变换。

void gp_Pnt::Mirror (const gp_Ax1& A1){ gp_Trsf T; T.SetMirror (A1); T.Transforms (coord);}

点关于面的对称变换。

void gp_Pnt::Mirror (const gp_Ax2& A2){ gp_Trsf T; T.SetMirror (A2); T.Transforms (coord);}

旋转,A1是旋转轴,Ang是旋转角度。

inline void gp_Pnt::Rotate (const gp_Ax1& A1, const Standard_Real Ang){ gp_Trsf T; T.SetRotation (A1, Ang); T.Transforms (coord);}

缩放

inline void gp_Pnt::Scale (const gp_Pnt& P, const Standard_Real S){ gp_XYZ XYZ = P.coord; XYZ.Multiply (1.0 - S); coord.Multiply (S); coord.Add (XYZ);}

变换

void gp_Pnt::Transform (const gp_Trsf& T){ if (T.Form() == gp_Identity) { } else if (T.Form() == gp_Translation) { coord.Add (T.TranslationPart ()); } else if (T.Form() == gp_Scale) { coord.Multiply (T.ScaleFactor ()); coord.Add (T.TranslationPart ()); } else if(T.Form() == gp_PntMirror) { coord.Reverse (); coord.Add (T.TranslationPart ()); } else { T.Transforms(coord); }}

平移

inline void gp_Pnt::Translate (const gp_Vec& V){ coord.Add (V.XYZ());}

 

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。