Reputation: 555
I am drawing and animating some objects using GDI. I need to detect a collision between these objects and to change their direction of motion. My question is : is there any algorithm for the detection of object collision by coordinates in C++?
Upvotes: 2
Views: 404
Reputation: 21419
If you are in 2D then I recommand you look into QuadTree. (Heavily used in GIS applications) This link has a C++ implementation of this special data structure
If you are in 3D then I recommand you look into OcTree.
Upvotes: 0
Reputation: 35069
My suggestion is to use a physics engine. Since you require only 2D, I suggest either Box2D or chipmunk. This is probably more easy than to implement it on your own.
Upvotes: 2