Skip to content

@turf/ellipse uses overly simplistic sampling method #1767

@cmbasnett

Description

@cmbasnett

The current sampling method for generating an ellipse in turf is to simply take samples at regular angle intervals (essentially identical to the @turf/circle implementation). This results in ugly and stretched ellipses where the difference between the length of the semi-major axes is appreciable. I propose that it should use arc-length intervals instead, as this results in a more natural representation of the ellipse.

Here is a gist of a drop-in replacement of @turf/ellipse that does arc-length interval sampling. You are also able to specify an accuracy value to tune performance vs. accuracy.

https://gist.github.com/cmbasnett/b62ea614e7b05f713b03835b3e93d4d3

Here's a jsfiddle with a side-by-side comparison of the two methods, highlighting the weaknesses of the current implementation (left: current, right: new hotness). http://jsfiddle.net/hkejm20t/88/

Screen Shot 2019-10-09 at 12 58 58 PM

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions