tisdag 21 februari 2017

Distance between 2D objects

Today we extended our 2D GJK into a version that finds the points on two objects that minimizes the distance between them, as well as calculates that distance. We decided to visualize this new information with a line between the two closest points.




The algorithm works even when the shapes are rotated. When there are several candidates that all give the same distance, only two points are chosen, as can be seen in the first image. When the objects are intersecting, no line is drawn.


We still haven't drawn polygons other than squares to test our algorithm with. However, we tried it with Unity's built in pill shape and we accidentally found out that our algorithm works even for rounded shapes. 



GJK 4 life

Inga kommentarer:

Skicka en kommentar