Convex hull algorithm in Unity - 1. 2D problem
- Convex hull algorithm
- To visualize offset area of freely moving vehicle over time, I developed 2D convex hull algorithm in Unity3D environment.
- There's nice library for convex hull algorithm, but is not possible to use it in Unity3D, since the library was implemented based on .NET 4.
- So, I implemented Graham's scan by myself, by firstly implement the algorithm in MATLAB and converting it into C#.
- Result in MATLAB
- Circles : trajectory of vertices of vehicle offset
- Lines : calculated convex hull
- Result in Unity3D
- Store vertices data 30 times per second
- Maintain up to 2 seconds data from current frame
- From those vertices, calculate convex hull in every frame and generate 3D shape by extruding result.
- For better visualization, add outlines for edges
- Next?
- 2D offset --> 3D offset
No comments:
Post a Comment