/// <summary>
/// 确定起始角及夹角
/// </summary>
/// <param name="p1">起始点</param>
/// <param name="p2">终点</param>
/// <param name="center">圆心</param>
/// <param name="arcInfoO">圆弧数据结构</param>
/// <param name="model">2:顺弧,3:逆弧</param>
private void DefiniteArcData(Postion_4D p1, Postion_4D p2, Postion_4D center, ArcInfo arcInfoO, uint model)
{
double cA = center.A;
double cB = center.B;
double angle1 = Math.Atan2(p1.B - cB, p1.A - cA);
double angle2 = Math.Atan2(p2.B - cB, p2.A - cA);
double EndAngle = ControlAngle(angle2 * 180 / Math.PI);
double BeAngle = ControlAngle(angle1 * 180 / Math.PI);
arcInfoO.BeginAngle = BeAngle;
if (BeAngle < EndAngle)
{//起始角>结束角
if (model == 2)//G02
arcInfoO.SweepAngle = -(360 - Math.Abs(BeAngle - EndAngle));
else//G03
arcInfoO.SweepAngle = Math.Abs(BeAngle - EndAngle);
}
else
{
if (model == 2)//G02
arcInfoO.SweepAngle = -(Math.Abs(BeAngle - EndAngle));
else//G03
arcInfoO.SweepAngle = 360 - Math.Abs(BeAngle - EndAngle);
}
}
/// <summary>
/// 控制角度范围0-360
/// </summary>
/// <param name="angle">传进来一个角度</param>
/// <returns>返回对应的0-360的角度</returns>
private double ControlAngle(double angle)
{
while (angle > 360)
{
angle -= 360;
}
while (angle < 0)
{
angle += 360;
}
return angle;
}
确定起始角及夹角
于 2023-12-22 10:05:41 首次发布