OpenCasCade数学库 - 点(gp_Pnt)

 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());
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值