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 GeoPolyline3 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
- GeoPolyline3
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, as for Flatten(double): every control point of a piece within it, or the second differences of a piece that is not rational small enough, or the middle control point of a conic low enough. Pieces are cut in halves, so the circle of radius 100 within 0.01 is 256 chords where 223 would hold.
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).
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.