Method Flatten
- Namespace
- GeometryHelper.Geometry
- Assembly
- GeometryHelper.dll
Flatten()
Approximates the loop as a straight polygon, cutting each arc finely enough that it strays no further than the automatic share of its radius.
public GeoPolygon2 Flatten()
Returns
- GeoPolygon2
The straight polygon, which every operation over regions can read.
Flatten(double)
Approximates the loop as a straight polygon, cutting each arc so that it strays no further than a chord tolerance.
public GeoPolygon2 Flatten(double chordTolerance)
Parameters
chordTolerancedoubleThe largest gap allowed between a piece and the arc it replaces, in drawing units. Zero picks the automatic share of each radius.
Returns
- GeoPolygon2
The straight polygon.
Remarks
The chords of an arc lie inside it, so a loop bulging outward encloses a little less once it is
flattened, and one bulging inward a little more. The promise holds however fine the tolerance and however
shallow the arc: the bottom of a rectangle 100 by 50 bowed 0.015 (a bulge of 0.0003, radius 83 333) cut within
1E-4 is 13 pieces and a polygon of area within 0.01 of 5 001.00000002, where one chord would leave 5 000. An arc that the tolerance
would cut into more than 1 048 576 pieces is refused. The result is a polygon, which merges corners closer together than the point tolerance (1E-3 by default),
so a tolerance whose chords would be shorter than that is not kept: an arc of radius 1 sweeping 1 radian within 1E-7
asks for 1 119 pieces and keeps 559, straying 3.99E-7 from the arc, where the old cut stopped at 4 096 a turn, 652 pieces,
strayed 2.94E-7. Merged chords of up to twice the point tolerance can stray up to (2E-3)² / 8 r from an arc of radius r,
5E-7 on a radius of 1, further than a coarser cut that kept its corners. The writers (ObjWriter, Wkt,
DxfWriter) keep every chord.
A loop so small that the merge would leave it fewer than three corners keeps every corner of its chords instead: the square 0.0005 by 0.0005 flattens to its four corners, and with its sides bowed by a bulge of 0.2 to the corners of their chords, where both were refused as having fewer than three corners.
Exceptions
- ArgumentOutOfRangeException
Thrown when the tolerance is negative or not a number, or needs more than 1 048 576 pieces for one arc.