Method Flatten
- Namespace
- GeometryHelper.Geometry
- Assembly
- GeometryHelper.dll
Flatten(double)
Approximates the spline as a chain of straight pieces, none of which strays further from it than a chord tolerance.
public GeoPolyline2 Flatten(double chordTolerance)
Parameters
chordTolerancedoubleThe largest gap allowed between the spline and the chain, in drawing units; above nought. There is no automatic one: a spline has no radius to take a share of.
Returns
- GeoPolyline2
The chain, from the start of the spline to its end, its corners on the spline.
Remarks
The promise holds however fine the tolerance, however sharp the bend and whatever the weights: every span is cut in halves until the piece is within the tolerance of the chord from its start to its end, which three proofs can say: every control point of a piece is within it (a piece lies in the hull of its control points); or, for a piece that is not rational, the second differences of its control points are small enough; or, for a rational quadratic, a conic, the height of its middle control point is. The circle of radius 100 within 0.01 is 256 chords, every corner on the circle, where 223 would hold, since pieces are cut in halves; the arch of (0, 0), (100, 150), (200, 150), (300, 0) within 0.01 is 128 chords.
A tolerance that would need more than 1 048 576 pieces is refused. The result is a chain, which merges corners
closer together than the point tolerance (1E-3 by default), so a tolerance whose pieces would be shorter than that
is not kept, as for Flatten(double); the writers (ObjWriter, Wkt,
DxfWriter) keep every piece.
A spline no longer than the point tolerance, all of it within the tolerance of its start, which a chain would merge into one point, is the chain of its corners as they are, the repeats of one point to the bit left out: the part 0.000245 long that Split(double) at a millionth cuts off the fit through (0, 0), (30, 20), (60, -10), (100, 0) is the chord from its start to its end, where it was refused. Split(double) keeps such a part, exactly, as it keeps any other.
Exceptions
- ArgumentOutOfRangeException
Thrown when the tolerance is not a positive number, or needs more than 1 048 576 pieces.
- ArgumentException
Thrown when every corner the spline is cut at is the same point, to the bit: a spline that stands still, or a closed one whose chord tolerance is so large that it is cut at its ends alone.