collision detection with rectangles or circles
1 view (last 30 days)
Show older comments
I am using the functions "rectangle" and "viscircles" in order to create objects in a graph.
obstacle_rect = rectangle('position',[6 2 2 2],'EdgeColor','r','LineWidth',2)
centers = [2.5 5; 4 3.5; 5.4 8.3; 8.2 6.22;];
radii = [0.5; 0.5; 1.5; 0.8];
obstacle_round = viscircles(centers, radii+r)
Now when plotting new vertices in the graph, I would like to test whether this vertex is inside the object or not (collision detection). I was thinking of doing this by calculating the distance between the vertex and some coordinates of the object. The issue is I don't know how to extract information out of the rectangles or circles as they are saved as a "group" in the workspace. I need a way to access the array 'position' somehow but in the help section I couldn't find anything on it.
Additionally, I would like to know if there might be a better way to determine whether a vertex is in collision with an object.
(I am using a student edition of Matlab 2016a with pretty much all of the available toolboxes.) Let me know if there is any information missing in order for this to be answered.
Thanks in advance.
0 Comments
Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!