/// <summary> /// 根据圆心,圆上起始点,结束点及圆的时针方向计算圆弧凸度 /// </summary> /// <param name="center">圆心</param> /// <param name="startPoint">起始点</param> /// <param name="endPoint">结束点</param> /// <param name="clockwise">时针方向</param> /// <returns></returns> public static double GetBulgeFromTwoPointsAndCenter(UnitPoint center, UnitPoint startPoint, UnitPoint endPoint, bool clockwise) { double startAngle = HitUtil.LineAngleR(center, startPoint, 0); double endAngle = HitUtil.LineAngleR(center, endPoint, 0); double sweepAngle = HitUtil.CalAngleSweep(HitUtil.RadiansToDegrees(startAngle), HitUtil.RadiansToDegrees(endAngle), clockwise); sweepAngle = Math.Abs(HitUtil.DegreesToRadians(sweepAngle) / 4); double bulge = Math.Tan(sweepAngle); bulge = clockwise ? -bulge : bulge; return(bulge); }
private static double IsCorrectCenter(UnitPoint center, double radius, double bulge, UnitPoint p1, UnitPoint p2) { double startAngle = HitUtil.RadiansToDegrees(HitUtil.LineAngleR(center, p1, 0)); double endAngle = HitUtil.RadiansToDegrees(HitUtil.LineAngleR(center, p2, 0)); bool clockwise = bulge >= 0 ? false : true; double sweepAngle = HitUtil.CalAngleSweep(startAngle, endAngle, clockwise); double midAngle = startAngle + sweepAngle / 2; UnitPoint midPoint = new UnitPoint(radius * Math.Cos(HitUtil.DegreesToRadians(midAngle)) + center.X, radius * Math.Sin(HitUtil.DegreesToRadians(midAngle)) + center.Y); double temp = BulgeToDegree(bulge); return(Math.Abs(temp - Math.Abs(sweepAngle))); }
public static UnitPoint GetBulgeMidPoint(UnitPoint p1, UnitPoint p2, double bulge) { bool clockwise = bulge >= 0 ? false : true; UnitPoint center = GetCenterByBulgeAndTwoPoints(p1, p2, bulge); float radius = (float)HitUtil.Distance(center, p1); float startAngle = (float)HitUtil.RadiansToDegrees(HitUtil.LineAngleR(center, p1, 0)); float EndAngle = (float)HitUtil.RadiansToDegrees(HitUtil.LineAngleR(center, p2, 0)); float sweepAngle = (float)HitUtil.CalAngleSweep(startAngle, EndAngle, clockwise); float midAngle = startAngle + sweepAngle / 2; UnitPoint midPoint = new UnitPoint(radius * Math.Cos(HitUtil.DegreesToRadians(midAngle)) + center.X, radius * Math.Sin(HitUtil.DegreesToRadians(midAngle)) + center.Y); return(midPoint); }