PreciseEllipticArcHelper.EllipticalArc Class
Definition
This class represents an elliptical arc on a 2D plane.
This class is adapted for use with WPF StreamGeometryContext, and needs to be created explicitly for each particular arc.
Some helpers
It can handle ellipses which are not aligned with the x and y reference axes of the plane, as well as their parts.
Another improvement is that this class can handle degenerated cases like for example very flat ellipses(semi-minor axis much smaller than semi-major axis) and drawing of very small parts of such ellipses at very high magnification scales.This imply monitoring the drawing approximation error for extremely small values.Such cases occur for example while drawing orbits of comets near the perihelion.
When the arc does not cover the complete ellipse, the lines joining the center of the ellipse to the endpoints can optionally be included or not in the outline, hence allowing to use it for pie-charts rendering. If these lines are not included, the curve is not naturally closed.
public class PreciseEllipticArcHelper.EllipticalArc
Constructors
| Name | Description |
|---|---|
| PreciseEllipticArcHelper.EllipticalArc (5 overloads) | Builds an elliptical arc composed of the full unit circle around (0,0) |
PreciseEllipticArcHelper.EllipticalArc overloads
PreciseEllipticArcHelper.EllipticalArc Constructor
Builds an elliptical arc composed of the full unit circle around (0,0)
public PreciseEllipticArcHelper.EllipticalArc()
PreciseEllipticArcHelper.EllipticalArc Constructor
Build a full ellipse from its canonical geometrical elements
public PreciseEllipticArcHelper.EllipticalArc(Avalonia.Point center, double a, double b, double theta)
Parameters
center Avalonia.Point
Center of the ellipse
a double
Semi-major axis
b double
Semi-minor axis
theta double
Orientation of the major axis with respect to the x axis
PreciseEllipticArcHelper.EllipticalArc Constructor
Builds an elliptical arc from its canonical geometrical elements
public PreciseEllipticArcHelper.EllipticalArc(Avalonia.Point center, double a, double b, double theta, double lambda1, double lambda2, bool isPieSlice)
Parameters
center Avalonia.Point
Center of the ellipse
a double
Semi-major axis
b double
Semi-minor axis
theta double
Orientation of the major axis with respect to the x axis
lambda1 double
Start angle of the arc
lambda2 double
End angle of the arc
isPieSlice bool
If true, the lines between the center of the ellipse and the endpoints are part of the shape (it is pie slice like)
PreciseEllipticArcHelper.EllipticalArc Constructor
Build a full ellipse from its canonical geometrical elements
public PreciseEllipticArcHelper.EllipticalArc(double cx, double cy, double a, double b, double theta)
Parameters
cx double
Abscissa of the center of the ellipse
cy double
Ordinate of the center of the ellipse
a double
Semi-major axis
b double
Semi-minor axis
theta double
Orientation of the major axis with respect to the x axis
PreciseEllipticArcHelper.EllipticalArc Constructor
Builds an elliptical arc from its canonical geometrical elements
public PreciseEllipticArcHelper.EllipticalArc(double cx, double cy, double a, double b, double theta, double lambda1, double lambda2, bool isPieSlice)
Parameters
cx double
Abscissa of the center of the ellipse
cy double
Ordinate of the center of the ellipse
a double
Semi-major axis
b double
Semi-minor axis
theta double
Orientation of the major axis with respect to the x axis
lambda1 double
Start angle of the arc
lambda2 double
End angle of the arc
isPieSlice bool
If true, the lines between the center of the ellipse and the endpoints are part of the shape (it is pie slice like)
Methods
| Name | Description |
|---|---|
| BuildArc (3 overloads) | Builds the arc outline using given StreamGeometryContext and default (max) Bezier curve degree and acceptable error of half a pixel (0.5) |
| Contains (4 overloads) | Tests if a specified Point2D is inside the boundary of a closed path derived from this arc. The closed path is derived with respect to the IsPieSlice value. |
| EstimateError | Estimate the approximation error for a sub-arc of the instance |
| GetBounds | Returns an integer Rectangle that completely encloses the closed path derived from this arc. The closed path is derived with respect to the IsPieSlice value. |
| Intersects (2 overloads) | Tests if the interior of the closed path derived from this arc intersects the interior of a specified rectangular area. The closed path is derived with respect to the IsPieSlice value. |
| PointAt | Get the elliptical arc point for a given angular parameter |
| SetDefaultFlatness | Sets the default flatness for Bezier curve approximation |
| SetMaxDegree | Sets the maximal degree allowed for Bezier curve approximation. |
BuildArc overloads
BuildArc Method
Builds the arc outline using given StreamGeometryContext and default (max) Bezier curve degree and acceptable error of half a pixel (0.5)
public void BuildArc(Avalonia.Media.StreamGeometryContext path)
Parameters
path Avalonia.Media.StreamGeometryContext
A StreamGeometryContext to output the path commands to
BuildArc Method
ArcTo Helper for StreamGeometryContext
public void BuildArc(Avalonia.Media.StreamGeometryContext path, Avalonia.Point p1, Avalonia.Point p2, Avalonia.Size size, double theta, bool isLargeArc, bool clockwise)
Parameters
path Avalonia.Media.StreamGeometryContext
Target path
Start point
End point
size Avalonia.Size
Ellipse radii
theta double
Ellipse theta (angle measured from the abscissa)
isLargeArc bool
Large Arc Indicator
clockwise bool
Clockwise direction flag
BuildArc Method
Builds the arc outline using given StreamGeometryContext
public void BuildArc(Avalonia.Media.StreamGeometryContext path, int degree, double threshold, bool openNewFigure)
Parameters
path Avalonia.Media.StreamGeometryContext
A StreamGeometryContext to output the path commands to
degree int
degree of the Bezier curve to use
threshold double
acceptable error
openNewFigure bool
if true, a new figure will be started in the specified StreamGeometryContext
Contains overloads
Contains Method
Tests if a specified Point2D is inside the boundary of a closed path derived from this arc. The closed path is derived with respect to the IsPieSlice value.
public bool Contains(Avalonia.Point p)
Parameters
Test point
Returns
bool
true if the specified point is inside a closed path derived from this arc
Contains Method
Tests if the interior of a closed path derived from this arc entirely contains the specified Rectangle2D. The closed path is derived with respect to the IsPieSlice value.
public bool Contains(Avalonia.Rect r)
Parameters
Test rectangle
Returns
bool
True if the interior of a closed path derived from this arc entirely contains the specified Rectangle2D; false otherwise
Contains Method
Tests if the specified coordinates are inside the closed shape formed by this arc. If this is not a pie, then a shape derived by adding a closing chord is considered.
public bool Contains(double x, double y)
Parameters
x double
Abscissa of the test point
y double
Ordinate of the test point
Returns
bool
True if the specified coordinates are inside the closed shape of this arc
Contains Method
Tests if the interior of a closed path derived from this arc entirely contains the specified rectangular area. The closed path is derived with respect to the IsPieSlice value.
public bool Contains(double x, double y, double w, double h)
Parameters
x double
Abscissa of the upper-left corner of the test rectangle
y double
Ordinate of the upper-left corner of the test rectangle
w double
Width of the test rectangle
h double
Height of the test rectangle
Returns
bool
true if the interior of a closed path derived from this arc entirely contains the specified rectangular area; false otherwise
EstimateError Method
Estimate the approximation error for a sub-arc of the instance
public double EstimateError(int degree, double etaA, double etaB)
Parameters
degree int
Degree of the Bezier curve to use (1, 2 or 3)
etaA double
Start angle of the sub-arc
etaB double
End angle of the sub-arc
Returns
double
Upper bound of the approximation error between the Bezier curve and the real ellipse
GetBounds Method
Returns an integer Rectangle that completely encloses the closed path derived from this arc. The closed path is derived with respect to the IsPieSlice value.
public Avalonia.Rect GetBounds()
Returns
Intersects overloads
Intersects Method
Tests if the interior of the closed path derived from this arc intersects the interior of a specified rectangular area. The closed path is derived with respect to the IsPieSlice value.
public bool Intersects(Avalonia.Rect r)
Parameters
Returns
bool
Intersects Method
Tests if the interior of the closed path derived from this arc intersects the interior of a specified rectangular area. The closed path is derived with respect to the IsPieSlice value.
public bool Intersects(double x, double y, double w, double h)
Parameters
x double
y double
w double
h double
Returns
bool
PointAt Method
Get the elliptical arc point for a given angular parameter
public Avalonia.Point PointAt(double lambda)
Parameters
lambda double
Angular parameter for which point is desired
Returns
The desired elliptical arc point location
SetDefaultFlatness Method
Sets the default flatness for Bezier curve approximation
public void SetDefaultFlatness(double defaultFlatness)
Parameters
defaultFlatness double
default flatness (must be greater than 1e-10)
Exceptions
SetMaxDegree Method
Sets the maximal degree allowed for Bezier curve approximation.
public void SetMaxDegree(int maxDegree)
Parameters
maxDegree int
Maximal allowed degree (must be between 1 and 3)
Exceptions
Properties
| Name | Description |
|---|---|
| DrawInOppositeDirection | No summary available. |
DrawInOppositeDirection Property
public bool DrawInOppositeDirection { get; set; }