Skip to content

Commit 2023202

Browse files
committed
changed EllipzicalArcLineSegment Parameter and updated docs
1 parent 46b3a3c commit 2023202

2 files changed

Lines changed: 25 additions & 25 deletions

File tree

src/ImageSharp.Drawing/Shapes/EllipticalArcLineSegment.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public sealed class EllipticalArcLineSegment : ILineSegment
1616
private const float MinimumSqrDistance = 1.75f;
1717
private readonly PointF[] linePoints;
1818
private PointF center;
19-
private readonly float firstRadius;
20-
private readonly float secondRadius;
19+
private readonly float radiusX;
20+
private readonly float radiusY;
2121
private readonly float rotation;
2222
private readonly float startAngle;
2323
private readonly float sweepAngle;
@@ -26,20 +26,20 @@ public sealed class EllipticalArcLineSegment : ILineSegment
2626
/// <summary>
2727
/// Initializes a new instance of the <see cref="EllipticalArcLineSegment"/> class.
2828
/// </summary>
29-
/// <param name="center"> The center point of the ellipsis that the arc is a part of</param>
30-
/// <param name="firstRadius">First radius of the ellipsis</param>
31-
/// <param name="secondRadius">Second radius of the ellipsis</param>
32-
/// <param name="rotation">The rotation of First radius to the X-Axis in degree</param>
33-
/// <param name="startAngle">The Start angle of the ellipsis in degree </param>
34-
/// <param name="sweepAngle"> The sweeping angle of the arc in degree</param>
35-
/// <param name="transformation">The TRanformation matrix, that should be used on the arc</param>
36-
public EllipticalArcLineSegment(PointF center, float firstRadius, float secondRadius, float rotation, float startAngle, float sweepAngle, Matrix3x2 transformation)
29+
/// <param name="center"> The center point of the ellipsis the arc is a part of.</param>
30+
/// <param name="radiusX">X radius of the ellipsis.</param>
31+
/// <param name="radiusY">Y radius of the ellipsis.</param>
32+
/// <param name="rotation">The rotation of (<paramref name="radiusX"/> to the X-axis and (<paramref name="radiusY"/> to the Y-axis,measured in degrees anticlockwise.</param>
33+
/// <param name="startAngle">The Start angle of the ellipsis, measured in degrees anticlockwise from the Y-axis.</param>
34+
/// <param name="sweepAngle"> The angle between (<paramref name="startAngle"/> and the end of the arc. </param>
35+
/// <param name="transformation">The Tranformation matrix, that should be used on the arc.</param>
36+
public EllipticalArcLineSegment(PointF center, float radiusX, float radiusY, float rotation, float startAngle, float sweepAngle, Matrix3x2 transformation)
3737
{
38-
Guard.MustBeGreaterThan(firstRadius, 0, nameof(firstRadius));
39-
Guard.MustBeGreaterThan(secondRadius, 0, nameof(secondRadius));
38+
Guard.MustBeGreaterThan(radiusX, 0, nameof(radiusX));
39+
Guard.MustBeGreaterThan(radiusY, 0, nameof(radiusY));
4040
this.center = center;
41-
this.firstRadius = firstRadius;
42-
this.secondRadius = secondRadius;
41+
this.radiusX = radiusX;
42+
this.radiusY = radiusY;
4343
this.rotation = rotation % 360;
4444
this.startAngle = startAngle % 360;
4545
this.transformation = transformation;
@@ -78,7 +78,7 @@ public EllipticalArcLineSegment Transform(Matrix3x2 matrix)
7878
return this;
7979
}
8080

81-
return new EllipticalArcLineSegment(this.center, this.firstRadius, this.secondRadius, this.rotation, this.startAngle, this.sweepAngle, Matrix3x2.Multiply(this.transformation, matrix));
81+
return new EllipticalArcLineSegment(this.center, this.radiusX, this.radiusY, this.rotation, this.startAngle, this.sweepAngle, Matrix3x2.Multiply(this.transformation, matrix));
8282
}
8383

8484
/// <summary>
@@ -151,8 +151,8 @@ private List<PointF> GetDrawingPoints(float start, float end, int depth)
151151

152152
private PointF CalculatePoint(float angle)
153153
{
154-
float x = (this.firstRadius * MathF.Sin(MathF.PI * angle / 180) * MathF.Cos(MathF.PI * this.rotation / 180)) - (this.secondRadius * MathF.Cos(MathF.PI * angle / 180) * MathF.Sin(MathF.PI * this.rotation / 180)) + this.center.X;
155-
float y = (this.firstRadius * MathF.Sin(MathF.PI * angle / 180) * MathF.Sin(MathF.PI * this.rotation / 180)) + (this.secondRadius * MathF.Cos(MathF.PI * angle / 180) * MathF.Cos(MathF.PI * this.rotation / 180)) + this.center.Y;
154+
float x = (this.radiusX * MathF.Sin(MathF.PI * angle / 180) * MathF.Cos(MathF.PI * this.rotation / 180)) - (this.radiusY * MathF.Cos(MathF.PI * angle / 180) * MathF.Sin(MathF.PI * this.rotation / 180)) + this.center.X;
155+
float y = (this.radiusX * MathF.Sin(MathF.PI * angle / 180) * MathF.Sin(MathF.PI * this.rotation / 180)) + (this.radiusY * MathF.Cos(MathF.PI * angle / 180) * MathF.Cos(MathF.PI * this.rotation / 180)) + this.center.Y;
156156
var currPoint = new PointF(x, y);
157157
return PointF.Transform(currPoint, this.transformation);
158158
}

src/ImageSharp.Drawing/Shapes/PathBuilder.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,16 @@ public PathBuilder AddBezier(PointF startPoint, PointF controlPoint1, PointF con
202202
/// <summary>
203203
/// Adds a elliptical arc to the current figure
204204
/// </summary>
205-
/// <param name="center">center point of the arc</param>
206-
/// <param name="firstRadius">first radius</param>
207-
/// <param name="secondRadius">second radius</param>
208-
/// <param name="rotation">rotation of the first radius to the x Axis in degree</param>
209-
/// <param name="startAngle">starting angle of arc in degree</param>
210-
/// <param name="sweepAngle">sweeping angel of the arc in degree</param>
205+
/// <param name="center"> The center point of the ellipsis the arc is a part of.</param>
206+
/// <param name="radiusX">X radius of the ellipsis.</param>
207+
/// <param name="radiusY">Y radius of the ellipsis.</param>
208+
/// <param name="rotation">The rotation of (<paramref name="radiusX"/> to the X-axis and (<paramref name="radiusY"/> to the Y-axis,measured in degrees anticlockwise.</param>
209+
/// <param name="startAngle">The Start angle of the ellipsis, measured in degrees anticlockwise from the Y-axis.</param>
210+
/// <param name="sweepAngle"> The angle between (<paramref name="startAngle"/> and the end of the arc. </param>
211211
/// <returns>The <see cref="PathBuilder"/></returns>
212-
public PathBuilder AddEllipticalArc(PointF center, float firstRadius, float secondRadius, float rotation, float startAngle, float sweepAngle)
212+
public PathBuilder AddEllipticalArc(PointF center, float radiusX, float radiusY, float rotation, float startAngle, float sweepAngle)
213213
{
214-
this.currentFigure.AddSegment(new EllipticalArcLineSegment(center, firstRadius, secondRadius, rotation, startAngle, sweepAngle, this.currentTransform));
214+
this.currentFigure.AddSegment(new EllipticalArcLineSegment(center, radiusX, radiusY, rotation, startAngle, sweepAngle, this.currentTransform));
215215

216216
return this;
217217
}

0 commit comments

Comments
 (0)