public static UnitPoint GetBulgeCenter(UnitPoint vertex, UnitPoint cutoffPoint, UnitPoint cutoffPoint2, double radius) { UnitPoint midPoint = HitUtil.LineMidpoint(cutoffPoint, cutoffPoint2); double midAngle = HitUtil.LineAngleR(vertex, midPoint, 0); double sideLen = GetDistanceBetweenVertexAndCutoffPoint(radius, midAngle * 2); double vertexToCenter = radius * radius + sideLen * sideLen; UnitPoint center = HitUtil.LineEndPoint(vertex, midAngle, vertexToCenter); return(center); }
/// <summary> /// 获取离交点距离一定的点 /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> /// <param name="p3"></param> /// <param name="radius"></param> /// <returns></returns> public static List <UnitPoint> GetCufPoint(UnitPoint p1, UnitPoint p2, UnitPoint p3, double radius) { List <UnitPoint> cutPoints = new List <UnitPoint>(); double angle = HitUtil.LineAngleR(p2, p1, 0); UnitPoint cutPoint = HitUtil.LineEndPoint(p2, angle, radius); cutPoints.Add(cutPoint); angle = HitUtil.LineAngleR(p2, p3, 0); cutPoint = HitUtil.LineEndPoint(p2, angle, radius); cutPoints.Add(cutPoint); return(cutPoints); }
public static List <UnitPoint> GetCufoffPoint(UnitPoint p1, UnitPoint p2, UnitPoint p3, double radius) { List <UnitPoint> cutoffPoints = new List <UnitPoint>(); double lineAngle = CalTwoLinesAngleFromThreePoints(p1, p2, p3); double length = radius / Math.Tan(lineAngle / 2); double preAngle = HitUtil.LineAngleR(p2, p1, 0); UnitPoint prePoint = HitUtil.LineEndPoint(p2, preAngle, length); //UnitPoint prePoint = HitUtil.PointOnCircle(p2, length, preAngle); cutoffPoints.Add(prePoint); double nextAngle = HitUtil.LineAngleR(p2, p3, 0); UnitPoint nextPoint = HitUtil.LineEndPoint(p2, nextAngle, length); //UnitPoint nextPoint = HitUtil.PointOnCircle(p2, length, nextAngle); cutoffPoints.Add(nextPoint); return(cutoffPoints); }
private void GetMultiLineLeadLineParams(IDrawObject drawObject, LineInOutParamsModel leadInOutParamsModel) { MultiSegmentLineBase multiSegmentLine = drawObject as MultiSegmentLineBase; int segment = 0; if (multiSegmentLine != null) { //所在段数必须合法 segment = DrawingOperationHelper.GetPointInLineIndex(multiSegmentLine, this.p2); int nextIndex = (segment + 1 >= multiSegmentLine.PointCount && multiSegmentLine.IsCloseFigure) ? 0 : segment + 1; if (double.IsNaN(multiSegmentLine.Points[segment].Bulge)) { double partLen = HitUtil.Distance(multiSegmentLine.Points[segment].Point, this.p2); double allLen = HitUtil.Distance(multiSegmentLine.Points[segment].Point, multiSegmentLine.Points[nextIndex].Point); float percent = (float)(segment + partLen / allLen); leadInOutParamsModel.FigureTotalLength = (float)(DrawingOperationHelper.GetLengthByPositionInPolyLine(multiSegmentLine.Points, multiSegmentLine.IsCloseFigure, percent) / multiSegmentLine.SizeLength); //角度(p1p2与当前线段所成夹角或与圆弧在当前鼠标点位置的切点出的切线所成夹角) this.p2 = HitUtil.FindApparentIntersectPoint(this.p1, this.p2, multiSegmentLine.Points[segment].Point, multiSegmentLine.Points[nextIndex].Point); double lineAngle = HitUtil.LineAngleR(multiSegmentLine.Points[nextIndex].Point, multiSegmentLine.Points[segment].Point, 0); UnitPoint extensionCordPoint = HitUtil.LineEndPoint(multiSegmentLine.Points[segment].Point, lineAngle, 5); leadInOutParamsModel.LineInAngle = (float)BulgeHelper.CalTwoLinesAngleFromThreePoints(extensionCordPoint, this.p2, this.p1); multiSegmentLine.IsInnerCut = HitUtil.IsClockwiseByCross(this.p1, this.p2, extensionCordPoint) == multiSegmentLine.Clockwise ? false : true; } else { ArcModelMini arcModelMini = DrawingOperationHelper.GetArcParametersFromBulge(multiSegmentLine.Points[segment].Point, multiSegmentLine.Points[nextIndex].Point, (float)multiSegmentLine.Points[segment].Bulge); float percent = segment + DrawingOperationHelper.GetPercentInArcByPoint(arcModelMini, this.p2); leadInOutParamsModel.FigureTotalLength = (float)(DrawingOperationHelper.GetLengthByPositionInPolyLine(multiSegmentLine.Points, multiSegmentLine.IsCloseFigure, percent) / multiSegmentLine.SizeLength); bool isInner; leadInOutParamsModel.LineInAngle = DrawingOperationHelper.GetLeadLineAngleArc(this.p1, this.p2, arcModelMini.Center, arcModelMini.Clockwise, out isInner); multiSegmentLine.IsInnerCut = isInner; } } //长度(p1p2的长度) leadInOutParamsModel.LineInLength = (float)HitUtil.Distance(p1, p2); }