Class EllipseArc2D
- Namespace
- CADability.Curve2D
- Assembly
- CADability.dll
Describes an arc of an ellipse in 2D. Implements the ICurve2D interface
public class EllipseArc2D : Ellipse2D, ICurve2D, IQuadTreeInsertable, ISerializable, IDeserializationCallback
- Inheritance
-
EllipseArc2D
- Implements
- Inherited Members
Constructors
EllipseArc2D(GeoPoint2D, GeoVector2D, GeoVector2D, double, double, GeoPoint2D, GeoPoint2D, GeoPoint2D, GeoPoint2D)
Constructs an elliptical arc from its parametric data. The point at the parametric angle a is
center + cos(a)*majorAxis + sin(a)*minorAxis; the arc starts at startPar and sweeps by
sweepPar. The extreme points must match the ellipse (as computed by the principal axis transformation
in Geometry); Create(GeoPoint2D, GeoVector2D, GeoVector2D, GeoPoint2D, GeoPoint2D, bool) does all that and is the usual way to make an elliptical arc.
public EllipseArc2D(GeoPoint2D center, GeoVector2D majorAxis, GeoVector2D minorAxis, double startPar, double sweepPar, GeoPoint2D left, GeoPoint2D right, GeoPoint2D bottom, GeoPoint2D top)
Parameters
centerGeoPoint2Dcenter of the ellipse
majorAxisGeoVector2Dmajor axis, from the center to the end of the axis
minorAxisGeoVector2Dminor axis, from the center to the end of the axis
startPardoubleparametric angle of the start point, in radians
sweepPardoublesigned parametric sweep angle in radians, positive from the major axis towards the minor axis
leftGeoPoint2Dleftmost point of the full ellipse
rightGeoPoint2Drightmost point of the full ellipse
bottomGeoPoint2Dlowest point of the full ellipse
topGeoPoint2Dhighest point of the full ellipse
EllipseArc2D(SerializationInfo, StreamingContext)
Constructor required by deserialization
protected EllipseArc2D(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfoSerializationInfo
contextStreamingContextStreamingContext
Properties
EndDirection
The direction of the curve at the end point (see EndDirection). This base implementation returns the normalized direction at the last base point of the triangulation.
public override GeoVector2D EndDirection { get; }
Property Value
EndPoint
The end point of the curve (see EndPoint). This base implementation takes it from the last base point of the triangulation; setting it only replaces that base point and leaves the underlying geometry unchanged, which is acceptable for small corrections only. Curves with their own data override it.
public override GeoPoint2D EndPoint { get; set; }
Property Value
IsClosed
Tells whether the curve is closed (see IsClosed). This base implementation tests whether StartPoint and EndPoint coincide according to IsEqual(GeoPoint2D, GeoPoint2D).
public override bool IsClosed { get; }
Property Value
Length
The arc length of the curve, from its points. Derived classes, which know a closed form or the derivative, should override this. The length used to be taken from an approximation by arcs, which is short by up to some tenths of a percent (e.g. a sine curve, the unrolled miter cut of a tube).
public override double Length { get; }
Property Value
StartDirection
The direction of the curve at the start point (see StartDirection). This base implementation returns the normalized direction at the first base point of the triangulation.
public override GeoVector2D StartDirection { get; }
Property Value
StartPoint
The start point of the curve (see StartPoint). This base implementation takes it from the first base point of the triangulation; setting it only replaces that base point and leaves the underlying geometry unchanged, which is acceptable for small corrections only. Curves with their own data override it.
public override GeoPoint2D StartPoint { get; set; }
Property Value
Sweep
The total signed change of direction along the curve in radians (see Sweep). This base implementation computes it from an approximation of the curve by circular arcs (Approximate(bool, double)), which is cached; curves with a closed form override it.
public override double Sweep { get; }
Property Value
axisStart
The polar angle of the start point in radians, measured about the center from the major axis. Unlike the parametric start angle of the constructor this is the geometric angle of the ray from the center to the start point, as GDI+ expects it for drawing an arc of an ellipse.
public double axisStart { get; }
Property Value
axisSweep
The signed polar sweep angle from the start point to the end point in radians (see axisStart), positive counterclockwise; +2pi or -2pi for a full ellipse. Used for drawing with GDI+.
public double axisSweep { get; }
Property Value
Methods
AddToGraphicsPath(GraphicsPath, bool)
Appends this curve to a GDI+ GraphicsPath, which is used for drawing and printing with GDI+.
public override void AddToGraphicsPath(GraphicsPath path, bool forward)
Parameters
pathGraphicsPaththe path to append to
forwardbooltrue to append the curve in its own direction, false to append it reversed (from the end point to the start point)
Clone()
Returns an independent copy of this curve of the same type. Modifying the copy does not affect this curve.
public override ICurve2D Clone()
Returns
- ICurve2D
the copy
CloneReverse(bool)
Returns a copy of this curve (see Clone()) which is reversed when reverse is true, i.e.
start point and end point are exchanged and the parameter runs the other way round.
public override ICurve2D CloneReverse(bool reverse)
Parameters
reversebooltrue to reverse the copy, false to copy it as it is
Returns
- ICurve2D
the copy
Copy(ICurve2D)
Copies the data of the given object to this object. Both objects must be of the same type.
public override void Copy(ICurve2D toCopyFrom)
Parameters
toCopyFromICurve2DCopies the data of this object
Create(GeoPoint2D, GeoVector2D, GeoVector2D, GeoPoint2D, GeoPoint2D, bool)
Creates the elliptical arc on the ellipse with the given center and axes from startPoint to
endPoint. The axes need not be the principal axes nor perpendicular, they are converted first. The
points are assumed to lie on the ellipse (only their parametric angles are used); coincident points give a full ellipse.
public static EllipseArc2D Create(GeoPoint2D center, GeoVector2D majorAxis, GeoVector2D minorAxis, GeoPoint2D startPoint, GeoPoint2D endPoint, bool counterClock)
Parameters
centerGeoPoint2Dcenter of the ellipse
majorAxisGeoVector2Dfirst axis of the ellipse
minorAxisGeoVector2Dsecond axis of the ellipse
startPointGeoPoint2Dstart point on the ellipse
endPointGeoPoint2Dend point on the ellipse
counterClockbooltrue for a counterclockwise arc, false for a clockwise arc
Returns
- EllipseArc2D
the elliptical arc
DirectionAt(double)
Returns the direction of the curve at the provided normalized position.
public override GeoVector2D DirectionAt(double Position)
Parameters
PositiondoubleWhere to get the direction
Returns
- GeoVector2D
The direction
GetArea()
Returns the signed area swept by the line from the origin to the moving point of the curve, i.e. GetAreaFromPoint(GeoPoint2D) with the origin as reference point. For a closed curve this is the enclosed area, positive when the curve runs counterclockwise, negative when it runs clockwise.
public override double GetArea()
Returns
- double
the signed area
GetComplement()
Returns the complementary arc on the same ellipse: it starts at the end point of this arc, runs in the same direction and ends at the start point of this arc, so that both arcs together form the full ellipse.
public EllipseArc2D GetComplement()
Returns
- EllipseArc2D
the complementary arc
GetExtendedHitTest()
Returns an IQuadTreeInsertable interface. The HitTest Method of this interface returns true if the rectangle coincides with the infinite extension of this curve (unbounded curve). Most curves are not extendable and therefore simply return "this".
public override IQuadTreeInsertable GetExtendedHitTest()
Returns
GetExtent()
Returns the bounding rectangle of the curve (see GetExtent()). This base implementation takes the base points of the triangulation and adds the points where the direction of the curve changes its sign in x or y between two base points, found by a simple interpolation; the result may therefore be slightly imprecise.
public override BoundingRect GetExtent()
Returns
- BoundingRect
the extent
GetFused(ICurve2D, double)
Returnes a new curve of the same type which is the fusion of this curve with the provided curve, e.g. two overlapping lines build a longer line. Returnes null if the fusion is not possible (e.g. a line and an arc or two lines with different direction)
public override ICurve2D GetFused(ICurve2D toFuseWith, double precision)
Parameters
Returns
GetModified(ModOp2D)
Returns a ICurve which is this curve modified by m. The curve can be of different type, e.g. a Circle may return an Ellpse
public override ICurve2D GetModified(ModOp2D m)
Parameters
mModOp2D
Returns
GetObjectData(SerializationInfo, StreamingContext)
Writes the data of this object for the legacy binary serialization (ISerializable). Files are written in the JSON format (IJsonSerialize) now; the binary format is still read.
public void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInforeceives the data
contextStreamingContextthe destination of the serialization
HitTest(ref BoundingRect, bool)
Tests whether the curve touches or crosses the rectangle (see HitTest(ref BoundingRect, bool)). This base implementation tests the triangles of the triangulation and subdivides a hit triangle until the decision is certain.
public override bool HitTest(ref BoundingRect Rect, bool IncludeControlPoints)
Parameters
RectBoundingRectIncludeControlPointsbool
Returns
- bool
true if the curve and the rectangle have a point in common
Intersect(ICurve2D)
Calculates the intersection points of this curve with another curve. Each result carries the point and its parameters
on both curves (par1 on this curve, par2 on
IntersectWith). Depending on the types involved the result may also contain intersections on the
extensions of the curves (e.g. of two lines, or of the full circles of two arcs), recognizable by parameters outside
0.0 to 1.0; use IsParameterOnCurve(double) to filter them. The result is not sorted.
public override GeoPoint2DWithParameter[] Intersect(ICurve2D IntersectWith)
Parameters
IntersectWithICurve2Dthe other curve
Returns
- GeoPoint2DWithParameter[]
the intersection points, an empty array when there are none
Intersect(GeoPoint2D, GeoPoint2D)
Calculates the intersection points of this curve with the line from StartPoint to EndPoint.
Same as Intersect(ICurve2D) with a Line2D: par2 is the
parameter on that line (0.0 at StartPoint, 1.0 at EndPoint), and points on the
extension of the line or of this curve may be included.
public override GeoPoint2DWithParameter[] Intersect(GeoPoint2D StartPoint, GeoPoint2D EndPoint)
Parameters
StartPointGeoPoint2Dstart point of the line
EndPointGeoPoint2Dend point of the line
Returns
- GeoPoint2DWithParameter[]
the intersection points, an empty array when there are none
IsParameterOnCurve(double)
Determines, whether the given parameter denotes a point inside the bounds of the curve. i.e. the parameter must be greater or equal to 0.0 and less than or equal 1.0. The actual interval is a little bit extended according to the eps value.
public override bool IsParameterOnCurve(double par)
Parameters
pardoublethe parameter to test
Returns
- bool
true if on curve
MakeGeoObject(Plane)
Creates the 3d object that corresponds to this curve placed in the plane p: the 2d coordinates are
taken as coordinates in the coordinate system of the plane (see ToGlobal(GeoPoint2D)). A
Line2D yields a Line, a circle, arc or ellipse an Ellipse, a spline a
BSpline, a path a Path and so on.
public override IGeoObject MakeGeoObject(Plane p)
Parameters
pPlanethe plane to place the curve in
Returns
- IGeoObject
the 3d curve as an IGeoObject
MakePositivOriented()
Makes the axes a right-handed system (the minor axis to the left of the major axis). If they are left-handed, the minor axis is flipped and the parametric start and sweep angles are adapted so that the arc itself, including its direction, stays the same. Needed before drawing with GDI+, which assumes right-handed axes.
public void MakePositivOriented()
MinDistance(GeoPoint2D)
Returns the distance of the point to the curve. In opposite to Distance(GeoPoint2D) this method will return the distance to the unextended curve
public override double MinDistance(GeoPoint2D p)
Parameters
pGeoPoint2DPoint to compute the distance to
Returns
- double
the distance
PerpendicularFoot(GeoPoint2D)
Returns the foot points of the perpendiculars from fromHere onto the ellipse which lie inside this arc.
public override GeoPoint2D[] PerpendicularFoot(GeoPoint2D fromHere)
Parameters
fromHereGeoPoint2Dfrom this point
Returns
- GeoPoint2D[]
the foot points inside the arc
PointAt(double)
Returns the point of the curve at the provided normalized position
public override GeoPoint2D PointAt(double Position)
Parameters
PositiondoubleWhere to get the direction
Returns
- GeoPoint2D
The point
PositionOf(GeoPoint2D)
Returns the position of point p on the curve: 0.0 corresponds to the StartPoint 1.0 to the EndPoint
public override double PositionOf(GeoPoint2D p)
Parameters
Returns
Project(Plane, Plane)
The 2d-curve is assumed to reside in plane "fromPlane". It will be projected perpendicular onto the plane "toPlane".
public override ICurve2D Project(Plane fromPlane, Plane toPlane)
Parameters
Returns
- ICurve2D
the projected curve
ReinterpretParameter(ref double)
Some curves especially Arc and EllipseArc have two possibilities to define a parameter of a point outside the curve: either as a parameter less than 0 which means ahead of the startpoint or as a parameter greater than 1 behind the endpoint. This method brings the given parameter into the other system, that means a parameter less than 0 will become greater than 1 and vice versa. Parameters between 0 and 1 will remain unchanged as well as most curves will return false, because the double interpretation isnt meaningfull.
public override bool ReinterpretParameter(ref double p)
Parameters
pdoubleparameter to change
Returns
- bool
true if possible, false otherwise
Reverse()
Reverses the direction of this curve
public override void Reverse()
Trim(double, double)
Returns a new curve of the same type which is the part of this curve between the two normalized parameters. The curve
itself remains unchanged. Normally StartPos is less than EndPos; for a closed curve
(Circle2D, Ellipse2D) reversed parameters select the part that runs across the start point of
the curve, for other curves the behaviour depends on the type (a Line2D or Arc2D returns the
part in reversed direction).
public override ICurve2D Trim(double StartPos, double EndPos)
Parameters
Returns
- ICurve2D
the trimmed curve, or null when the result would be degenerate (e.g. an arc with zero sweep)