Content
I just learned this algorithm to simplified polyline, with Professor. Jose’s amazing tutorial. People who want to learn a bit more, should definitely follow this channel.
The idea is relatively simple, but the implementation could be thousands and millions way.
The goal of this algorithm is to reduce the points in one polyline(points + line), but still want to remain to soul(properity, or shape to be more specifically). There are tons of benefits by doing this, obvious one is that this can clearly releave your memory while speed up the computation time.
Implement
The method here is to recursively find the
farthest point
to the two segment endpoints. That’s it.
Dive into the Csharp code
Something should be took care
- epilson
- left points
- right points
- two lists combinition
- recursive function
- Point-Line distance
Because this blog is for recording something I have learned, it is definitely not detail-clear to everyone. Please refer to the Professor Jose’s tutorial video, if you want to have a clear idea of this.
code
crossProduct
Though in RhinoCommon, there are one predefined crossProduct method that we could use directly, it is convenient that we made by ourselves in the cases of bring this method to another Csharp-based platform.
1 | Vector3d crossProduct(Vector3d u, Vector3d v){ |
Point-Line distance
$$ \frac{\vec{AB} \times \vec{AP}}{| \vec{AB}|}$$
1 | double distToLine(Point3d P, Point3d A, Point3d B){ |
simplifyPolyline
1 | List<Point3d> simplifyPolyline(List<Point3d> points, double epsilon){ |
Note from reading Wiki
Application
The algorithm is used for the processing of vector graphics and cateographic generalization.
It does not always preserve the property of
non-self intersection
for curves which has led to the development of variant algorithms.
Like Jose mentioned in his video, this method is widely used in robotics to perform simplification and denoiseing of range data acuquired by a rotating range scanner
.