|
@@ -173,6 +173,11 @@ namespace SketchAssistant
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -578,10 +583,10 @@ namespace SketchAssistant
|
|
|
}
|
|
|
}
|
|
|
normalizePathDeclaration(pathElements);
|
|
|
- foreach(String s in pathElements)
|
|
|
- {
|
|
|
- Console.WriteLine(s);
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
List<Line> element = new List<Line>();
|
|
|
List<Point> currentLine = new List<Point>();
|
|
|
double lastBezierControlPointX= 0;
|
|
@@ -1084,11 +1089,11 @@ namespace SketchAssistant
|
|
|
|
|
|
private (List<Point>, double, double, double, double) parse_C(List<string> pathElements, double lastPositionX, double lastPositionY)
|
|
|
{
|
|
|
- Console.WriteLine("parsing C: ");
|
|
|
- for(int k= 0; k < 7; k++)
|
|
|
- {
|
|
|
- Console.WriteLine(pathElements.ElementAt(k));
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
pathElements.RemoveAt(0);
|
|
|
double x1 = Convert.ToDouble(pathElements.First(), CultureInfo.InvariantCulture);
|
|
|
pathElements.RemoveAt(0);
|
|
@@ -1355,7 +1360,7 @@ namespace SketchAssistant
|
|
|
double sin = Math.Sin(thetha / 180 * Math.PI);
|
|
|
double targetXTransformed = cos * nextPositionXRelative - sin * nextPositionYRelative;
|
|
|
double targetYTransformed = sin * nextPositionXRelative + cos * nextPositionYRelative;
|
|
|
- (double[], double[]) values = sampleEllipticArcBiasedNoRotation(rx, ry, nextPositionXRelative, nextPositionYRelative, largeArcFlag, sweepFlag);
|
|
|
+ (double[], double[]) values = sampleEllipticArcBiasedNoRotation(rx, ry, targetXTransformed, targetYTransformed, largeArcFlag, sweepFlag);
|
|
|
List<Point> result = new List<Point>();
|
|
|
for (int j = 0; j < values.Item1.Length; j++)
|
|
|
{
|
|
@@ -1450,7 +1455,7 @@ namespace SketchAssistant
|
|
|
|
|
|
Console.WriteLine("computed center of circle (relative): point1= (0,0), point2= (" + nextPositionXRelative + "," + nextPositionYRelative + "), center= (" + xC + "," + yC + ")");
|
|
|
|
|
|
- (double[], double[]) values = sampleCircleArcBiasedAroundCenter(-xC, -yC, nextPositionXRelative - xC, nextPositionYRelative - yC, r, sweepFlag);
|
|
|
+ (double[], double[]) values = sampleCircleArcBiasedAroundCenter(-xC, -yC, nextPositionXRelative - xC, nextPositionYRelative - yC, r, largeArcFlag, sweepFlag);
|
|
|
for (int j = 0; j < values.Item1.Length; j++)
|
|
|
{
|
|
|
values.Item1[j] = values.Item1[j] + xC;
|
|
@@ -1469,26 +1474,40 @@ namespace SketchAssistant
|
|
|
|
|
|
|
|
|
|
|
|
- private (double[], double[]) sampleCircleArcBiasedAroundCenter(double xStartPoint, double yStartPoint, double xFinalPoint, double yFinalPoint, double r, bool clockwise)
|
|
|
+ private (double[], double[]) sampleCircleArcBiasedAroundCenter(double xStartPoint, double yStartPoint, double xFinalPoint, double yFinalPoint, double r, bool largeArcFlag, bool clockwise)
|
|
|
{
|
|
|
double phiEnd = Math.Atan2(yFinalPoint, xFinalPoint);
|
|
|
double phiStart = Math.Atan2(yStartPoint, xStartPoint);
|
|
|
|
|
|
double angle = ((double)2 * Math.PI) / (double)samplingRateEllipse;
|
|
|
- int numberOfPoints = (int) Math.Ceiling(Math.Abs(phiEnd - phiStart) / angle);
|
|
|
+ double angleDifference = Math.Abs(phiStart - phiEnd);
|
|
|
+ if (angleDifference > 2 * Math.PI || angleDifference < 0) throw new Exception("angleDifference out of range: " + angleDifference);
|
|
|
+ if (largeArcFlag)
|
|
|
+ {
|
|
|
+ if (angleDifference < Math.PI) angleDifference = ((double)2 * Math.PI) - angleDifference;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(angleDifference > Math.PI) angleDifference = ((double)2 * Math.PI) - angleDifference;
|
|
|
+ }
|
|
|
+ int numberOfPoints = (int) Math.Ceiling(angleDifference / angle);
|
|
|
|
|
|
double[] xValues = new double[numberOfPoints];
|
|
|
double[] yValues = new double[numberOfPoints];
|
|
|
double phiCurrent = phiStart;
|
|
|
- for (int j = 0; j < numberOfPoints-1; j++)
|
|
|
+ Console.WriteLine("sampling circular arc around origin: from " + phiStart + " until " + phiEnd + ":");
|
|
|
+ Console.WriteLine("parsed start Point: (" + xStartPoint + "," + yStartPoint + ")");
|
|
|
+ for (int j = 0; j < numberOfPoints-1; j++)
|
|
|
{
|
|
|
if (clockwise) phiCurrent -= angle;
|
|
|
else phiCurrent += angle;
|
|
|
yValues[j] = Math.Sin(phiCurrent) * r;
|
|
|
xValues[j] = Math.Cos(phiCurrent) * r;
|
|
|
+ Console.WriteLine("parsed Point: (" + xValues[j] + "," + yValues[j] + ")");
|
|
|
}
|
|
|
xValues[numberOfPoints - 1] = xFinalPoint;
|
|
|
yValues[numberOfPoints - 1] = yFinalPoint;
|
|
|
+ Console.WriteLine("parsed final Point: (" + xValues[numberOfPoints - 1] + "," + yValues[numberOfPoints - 1] + ")");
|
|
|
|
|
|
return (xValues, yValues);
|
|
|
}
|