/// <summary> /// Is the point p on the arc and not on the gap /// </summary> /// <param name="p"></param> /// <returns></returns> private bool IsPointOnArc(GeoPoint2D p) { // we assume that the point is on the (full) ellipse and test here, whether it is on the actual arc if (Math.Abs(sweepPar - SweepAngle.Full) < 1e-10 || Math.Abs(sweepPar - SweepAngle.FullReverse) < 1e-10) { return(true); } if (Math.Abs(sweepPar) < 0.1 || Math.Abs(sweepPar) > SweepAngle.Full - 0.1) { // if start and endpoint are very close, then we cannot use "IsLeftOf", because it might be imprecise return(IsParameterOnCurve(PositionOf(p))); } else { if (sweepPar > 0.0) { return(p.IsLeftOf(endPoint, startPoint)); } else { return(p.IsLeftOf(startPoint, endPoint)); } } }
private bool crossingZero; // geht über die X-Achse private void RecalcQuadrant() { // Berechnung von start und sweep, wird benötigt für die GDI Darstellung Angle MajorAngle = majorAxis.Angle; double s = Math.Sin(MajorAngle); double c = Math.Cos(MajorAngle); ModOp2D toCenter = new ModOp2D(c, s, (-c * center.x - s * center.y), -s, c, (s * center.x - c * center.y)); GeoVector2D startVector = toCenter * startPoint - GeoPoint2D.Origin; GeoVector2D endVector = toCenter * endPoint - GeoPoint2D.Origin; start = startVector.Angle; sweep = new SweepAngle(start, endVector.Angle, sweepPar > 0.0); if (sweep == 0.0) { if (sweepPar > 0.0) { sweep = Math.PI * 2.0; } if (sweepPar < 0.0) { sweep = -Math.PI * 2.0; } } // Berechnung der betroffenen Quadranten startQuad = endQuad = -1; if (startPoint.IsLeftOf(top, right)) { startQuad = 0; } else if (startPoint.IsLeftOf(left, top)) { startQuad = 1; } else if (startPoint.IsLeftOf(bottom, left)) { startQuad = 2; } else if (startPoint.IsLeftOf(right, bottom)) { startQuad = 3; } if (startQuad == -1) { // der Startpunkt muss auf einer Ecke liegen double dmin, d; dmin = Geometry.Dist(startPoint, right); startQuad = 0; d = Geometry.Dist(startPoint, top); if (d < dmin) { startQuad = 1; dmin = d; } d = Geometry.Dist(startPoint, left); if (d < dmin) { startQuad = 2; dmin = d; } if (Geometry.Dist(startPoint, bottom) < dmin) { startQuad = 3; } } if (endPoint.IsLeftOf(top, right)) { endQuad = 0; } else if (endPoint.IsLeftOf(left, top)) { endQuad = 1; } else if (endPoint.IsLeftOf(bottom, left)) { endQuad = 2; } else if (endPoint.IsLeftOf(right, bottom)) { endQuad = 3; } if (endQuad == -1) { double dmin, d; dmin = Geometry.Dist(endPoint, right); endQuad = 0; d = Geometry.Dist(endPoint, top); if (d < dmin) { endQuad = 1; dmin = d; } d = Geometry.Dist(endPoint, left); if (d < dmin) { endQuad = 2; dmin = d; } if (Geometry.Dist(endPoint, bottom) < dmin) { endQuad = 3; } } if ((sweepPar > 0.0) == (GeoVector2D.Orientation(majorAxis, minorAxis) > 0)) { // crossingZero = right.IsLeftOf(endPoint,startPoint); // if (Precision.IsEqual(right,endPoint) && endQuad==0) crossingZero = true; // if (Precision.IsEqual(right,startPoint) && startQuad==3) crossingZero = true; crossingZero = (endQuad < startQuad); if (endQuad == startQuad) { crossingZero = sweepPar > Math.PI; } } else { // crossingZero = right.IsLeftOf(startPoint,endPoint); crossingZero = (startQuad < endQuad); if (endQuad == startQuad) { crossingZero = sweepPar < -Math.PI; } } }