@@ -46,7 +46,7 @@ public EllipticalArcLineSegment(PointF center, float firstRadius, float secondRa
4646 this . sweepAngle = sweepAngle ;
4747 if ( sweepAngle > 360 )
4848 {
49- sweepAngle = 360 ;
49+ this . sweepAngle = 360 ;
5050 }
5151
5252 this . linePoints = this . GetDrawingPoints ( ) ;
@@ -86,11 +86,10 @@ public EllipticalArcLineSegment Transform(Matrix3x2 matrix)
8686
8787 private PointF [ ] GetDrawingPoints ( )
8888 {
89- var points = new List < PointF > ( ) ;
89+ var points = new List < PointF > ( ) {
90+ this . calculatePoint ( this . startAngle )
91+ } ;
9092
91- float startX = ( float ) ( ( this . firstRadius * Math . Sin ( Math . PI * this . startAngle / 180 ) * Math . Cos ( Math . PI * this . rotation / 180 ) ) - ( this . secondRadius * Math . Cos ( Math . PI * this . startAngle / 180 ) * Math . Sin ( Math . PI * this . rotation / 180 ) ) + this . center . X ) ;
92- float startY = ( float ) ( ( this . firstRadius * Math . Sin ( Math . PI * this . startAngle / 180 ) * Math . Sin ( Math . PI * this . rotation / 180 ) ) + ( this . secondRadius * Math . Cos ( Math . PI * this . startAngle / 180 ) * Math . Cos ( Math . PI * this . rotation / 180 ) ) + this . center . Y ) ;
93- points . Add ( new PointF ( startX , startY ) ) ;
9493 for ( float i = this . startAngle ; i < this . startAngle + this . sweepAngle ; i ++ )
9594 {
9695 float end = i + 1 ;
@@ -114,14 +113,11 @@ private List<PointF> GetDrawingPoints(float start, float end, int depth)
114113
115114 var points = new List < PointF > ( ) ;
116115
117- float startX = ( float ) ( ( this . firstRadius * Math . Sin ( Math . PI * start / 180 ) * Math . Cos ( Math . PI * this . rotation / 180 ) ) - ( this . secondRadius * Math . Cos ( Math . PI * start / 180 ) * Math . Sin ( Math . PI * this . rotation / 180 ) ) + this . center . X ) ;
118- float startY = ( float ) ( ( this . firstRadius * Math . Sin ( Math . PI * start / 180 ) * Math . Sin ( Math . PI * this . rotation / 180 ) ) + ( this . secondRadius * Math . Cos ( Math . PI * start / 180 ) * Math . Cos ( Math . PI * this . rotation / 180 ) ) + this . center . Y ) ;
119-
120- float endX = ( float ) ( ( this . firstRadius * Math . Sin ( Math . PI * end / 180 ) * Math . Cos ( Math . PI * this . rotation / 180 ) ) - ( this . secondRadius * Math . Cos ( Math . PI * end / 180 ) * Math . Sin ( Math . PI * this . rotation / 180 ) ) + this . center . X ) ;
121- float endY = ( float ) ( ( this . firstRadius * Math . Sin ( Math . PI * end / 180 ) * Math . Sin ( Math . PI * this . rotation / 180 ) ) + ( this . secondRadius * Math . Cos ( Math . PI * end / 180 ) * Math . Cos ( Math . PI * this . rotation / 180 ) ) + this . center . Y ) ;
122- if ( ( new Vector2 ( endX , endY ) - new Vector2 ( startX , startY ) ) . LengthSquared ( ) < MinimumSqrDistance )
116+ PointF startP = calculatePoint ( start ) ;
117+ PointF endP = calculatePoint ( end ) ;
118+ if ( ( new Vector2 ( endP . X , endP . Y ) - new Vector2 ( startP . X , startP . Y ) ) . LengthSquared ( ) < MinimumSqrDistance )
123119 {
124- points . Add ( new PointF ( endX , endY ) ) ;
120+ points . Add ( endP ) ;
125121 }
126122 else
127123 {
@@ -133,6 +129,13 @@ private List<PointF> GetDrawingPoints(float start, float end, int depth)
133129 return points ;
134130 }
135131
132+ private PointF calculatePoint ( float angle )
133+ {
134+ float x = ( float ) ( ( this . firstRadius * Math . Sin ( Math . PI * angle / 180 ) * Math . Cos ( Math . PI * this . rotation / 180 ) ) - ( this . secondRadius * Math . Cos ( Math . PI * angle / 180 ) * Math . Sin ( Math . PI * this . rotation / 180 ) ) + this . center . X ) ;
135+ float y = ( float ) ( ( this . firstRadius * Math . Sin ( Math . PI * angle / 180 ) * Math . Sin ( Math . PI * this . rotation / 180 ) ) + ( this . secondRadius * Math . Cos ( Math . PI * angle / 180 ) * Math . Cos ( Math . PI * this . rotation / 180 ) ) + this . center . Y ) ;
136+ return new PointF ( x , y ) ;
137+ }
138+
136139 /// <summary>
137140 /// Returns the current <see cref="ILineSegment" /> a simple linear path.
138141 /// </summary>
0 commit comments