private Plane zPosition; // die Raum-Ebene, in deren Mittelpunkt der Kreis bezüglich seine 2d Darstellung liegt internal void RecalcUnitCircle() { // berechnen der beiden ModOps fromUnitCircle und toUnitCircle // Achtung: das berücksichtigt nicht ein Linkssystem. Das ist somit eigentlich falsch // im Linkssystem müsste das Vorzeichen von MinorRadius negativ sein, damit die Matrix stimmt! double MajorRadius = majorAxis.Length; double MinorRadius = minorAxis.Length; if (GeoVector2D.Orientation(majorAxis, minorAxis) < 0) { // eingeführt wg. dem Umdrehen eines Faces mit elliptischen Begrenzungen (11.3.15), Datei 97871_086103_032.cdb, nach Shell.AssertOutwardOrientation stimmt das Face Nr. 8 nicht mehr MinorRadius = -MinorRadius; } if (MajorRadius == 0.0 || MinorRadius == 0.0) { fromUnitCircle = toUnitCircle = ModOp2D.Identity; } else { Angle MajorAngle = majorAxis.Angle; double s = Math.Sin(MajorAngle); double c = Math.Cos(MajorAngle); toUnitCircle = new ModOp2D(c / MajorRadius, s / MajorRadius, (-c * center.x - s * center.y) / MajorRadius, -s / MinorRadius, c / MinorRadius, (s * center.x - c * center.y) / MinorRadius); fromUnitCircle = new ModOp2D(MajorRadius * c, -MinorRadius * s, center.x, MajorRadius * s, MinorRadius * c, center.y); } }
public void MakePositivOriented() { // stellt sicher, dass die majorAxis und minorAxis ein rechtssystem bilden if (GeoVector2D.Orientation(majorAxis, minorAxis) < 0) { minorAxis = -minorAxis; startPar = 2.0 * Math.PI - startPar; sweepPar = -sweepPar; RecalcQuadrant(); } }
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; } } }