This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is based on https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm, | |
with the requirement that the maximum norm is used for distance calculations. | |
The algorithm is as follows, described for R^2, but it is easily extensible to | |
arbitrary dimensions >2: | |
- given points p_1, ..., p_n, we start by constructing our funnel | |
by calculating | |
dp_1 = (p_2 - p_1) | |
x_1_top = (dp_1_y + epsilon) / dp_1_x |