Home

Awesome

simplify-csharp

Polyline simplifier

Example

Use the SimplificationHelpers class to quickly simplify a list of System.Windows.Point objects.

The library is non-intrusive and only requires methods for extracting x,y and z values as doubles and for comparing two objects of the given type.

    double tolerance = 0.5;
    bool highQualityEnabled = false;
    var simplifiedPoints = SimplificationHelpers.Simplify<Point>(
                    Points,
                    (p1, p2) => p1 == p2,
                    (p) => p.X, 
                    (p) => p.Y,
                    tolerence,
                    highQualityEnabled
                    );

Please note The algorithm squares differences of x, y and z coordinates. If this difference is less than 1, the square of it will get even less. In such cases, the tolerance has negative effect.

Solution: multiply your coordinates by a factor so the values are shifted in a way so that taking the square of the differences creates greater values.

Demo

To demo the algorithm, compile and run the SimplifyCSharpDemo project and scribble some lines in the user input canvas. Click on Simplify to run the algorithm and draw the result in the output canvas.

Demo Screenshot

Licence

TODO

Alternatives / Infos