Изменения

Перейти к: навигация, поиск

Упрощение полигональной цепи

132 байта убрано, 18:39, 27 февраля 2012
Псевдокод
===Псевдокод===
<texcode>Douglas–PeuckerDouglasPeucker(int first, int last, double eps)</texcode>:<code>Для всех точек междуmax = -infinity</code> :<texcode>firstindex = -1</tex> <code>и:</code> for (int i = first + 1; i <tex>last; i++)</texcode>::<code>Если точка удалена дальше чем предыдущие запомнить ее вdistance = dist(points[i],segment(points[first],points[last]))</code> ::<texcode>if (distance >max&& distance > eps)</texcode>:::<code>Если расстояние от</code> <tex>max= distance, index = i</tex> <code>до отрезка:</code> <tex>firstif(index != -last1)</tex> <code>меньше</code> <tex>eps</tex>::<code>Вернутьсяreturn</code>:<code>Иначеelse</code>::<code>Добавить точку</code> <tex>max</tex> <code>в ответanswer[index] = true</code>::<texcode>DouglasPeucker(first, max, eps)</texcode>::<texcode>DouglasPeucked(max, last, eps)</texcode>
===Пример===
304
правки

Навигация