Table of Contents

Method Flatten

Namespace
GeometryHelper.Geometry
Assembly
GeometryHelper.dll

Flatten()

Approximates the chain as a straight one, cutting each arc finely enough that it strays no further than the automatic share of its radius.

public GeoPolyline2 Flatten()

Returns

GeoPolyline2

The straight chain, which every operation over regions can read.

Remarks

This is where exactness ends. A chain with no arcs comes across whole; one with arcs comes across as chords, as close as the tolerance says and no closer.

Flatten(double)

Approximates the chain as a straight one, cutting each arc so that it strays no further than a chord tolerance.

public GeoPolyline2 Flatten(double chordTolerance)

Parameters

chordTolerance double

The largest gap allowed between a piece and the arc it replaces, in drawing units. Zero picks the automatic share of each radius.

Returns

GeoPolyline2

The straight chain.

Remarks

The promise holds however fine the tolerance and however shallow the arc: an arc of bulge 0.0003 on a chord of 100 (radius 83 333, 0.015 deep) cut within 1E-4 is 13 pieces, not the one chord. An arc that the tolerance would cut into 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 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 chain so small that the merge would leave it one corner keeps every corner of its chords instead: the chain (0, 0), (0.0005, 0), (0.0005, 0.0005) with its second leg bowed by a bulge of 0.4 flattens to the corners of the chords of that leg, where it was refused as having fewer than two corners.

Exceptions

ArgumentOutOfRangeException

Thrown when the tolerance is negative or not a number, or needs more than 1 048 576 pieces for one arc.