openframeworks/openFrameworks — pull request #2053 by memo (2013-05-15 21:53:24+00:00)
Title: Feature of polyline sampling

New features to ofPolyline to:
- resample a single point anywhere along the ofPolyline (either by fractional index, or percentage, or distance)
- cache and get normals, lengths, curvature, rotation vector, at any point along the path (again by fractional index, percentage, distance etc).
- find the nearest index at a given length along the path
- insert a vertex at any given point
- required utils and mods to make the above possible

Regarding method names these are of couse open to discussion to be inline with OF conventions. But a few points:
- I chose 'xxxxPercent', to be inline with the OF 'setAnchorPercent' type methods (which take a normalized 0...1 value)
- I chose 'getAngle' (which returns degrees), to be inline with the OF getAngle methods (only the rad returning methods have a Rad suffix, while the deg returning methods have no suffix. So I'm assuming no suffix means Deg)

There is also an app in devApps/ofPolyline resample tester. This is quite ugly at this stage and probably quite confusing to anyone who opens it. It is not really meant to be educational, but a thorough systematic testing of all of the new features. It could be prettified and made into a public example. Or more suitable public examples can be written from scratch which are actually useful :)