How do I check if 2 rotated rectangles intersect?

2,366 views
Skip to first unread message

zachary...@gmail.com

unread,
Sep 5, 2014, 1:31:45 PM9/5/14
to golan...@googlegroups.com
I am currently making a server for a game and I have the server make rectangles for the game entities (simple object with x, y, width, height, rotation) it needs to keep track of. I now need to see if they collide on the server but I'm not sure how to do so in GO. I have been looking it up but it seems like a lot of the methods people use are using built in functions for their language (java/c++) but I don't think GO has any like that. Any help would be appreciated!

Kevin Gillette

unread,
Sep 5, 2014, 2:18:29 PM9/5/14
to golan...@googlegroups.com, zachary...@gmail.com
The approach is the same in Go as it is for any language; collision detection ultimately uses math, not language features. First check to see if their axis-aligned bounding boxes overlap (if they don't, then no collision is possible), then google for polygon collision detection to see what further checks should be made. There are numerous optimizations that apply to rotated rectangles and other simple shapes.

Klaus Post

unread,
Sep 6, 2014, 7:50:57 AM9/6/14
to golan...@googlegroups.com, zachary...@gmail.com
Reply all
Reply to author
Forward
0 new messages