Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to simplify/optimize a 3d path?

I have a bunch of points in 3d ( an array that contains objects with x,y,z properties ).

My problem is that there are a lot of unnecessary points as illustrated in the image bellow:

3d path
(source: lifesine.eu)

How can I cleanup this path ?

At the moment the first thing that comes to mind is to

  • create an array for the optimized path
  • loop though all the points starting with index 1 instead of 0, and get the 'direction' for the path. If the direction changes, add the last of the two points( the current, not the previous ) to the optimized array.

The advantage is that the points are stored in a drawing order, so that makes them a path, not just random ( not sorted ) points.

Note: I am using actionscript 3, but I can understand syntax in other languages or pseudo code.

Thank you!

like image 654
George Profenza Avatar asked Feb 28 '23 08:02

George Profenza


1 Answers

Check out Ramer-Douglas-Peucker algorithm

like image 145
Stephen Nutt Avatar answered Mar 11 '23 20:03

Stephen Nutt