Esempio n. 1
0
//计算弧线上距离pt最近的点
PNT XArc::NearPt(PNT pt)
{
	float prop = Proportion(pt);

	//始点方向
	PNT dirBpt = m_StartPt-m_Cen;
	dirBpt.Normalize();
	
	//终点方向
	PNT dirEpt = m_EndPt-m_Cen;
	dirEpt.Normalize();

	PNT dir = dirBpt^dirEpt;//dirBpt.CrossProduct(dirEpt);
	
	float angle;
	if(dir*m_Normal>0)//始点,终点夹角小于180度
		angle = acos(dirBpt*dirEpt);
	else
		angle = PI*2.0-acos(dirBpt*dirEpt);

	float Rotangle = prop*angle;//旋转角度
	
	//最近点
	PNT nearpt = m_StartPt;
	nearpt.Rotate(m_Cen,m_Normal,Rotangle);
	
	return nearpt;
}
SizerItem grow(wxWindow* window){
  return {window, Proportion(1), wxEXPAND};
}
SizerItem center(wxSizer* sizer){
  return {sizer, Proportion(0), wxALIGN_CENTER};
}
SizerItem grow(wxSizer* sizer){
  return {sizer, Proportion(1), wxEXPAND};
}