# Collision detection & locating objects coordinates

Hi,
(working in a viewed from above world)
I have a sphere that depending on user interaction rotates(z) then moves a given distance on the screen. I have created a series of flexible ‘walls’ on the screen from a massive array of coordinates for single dots that have all been plotted as small circles at each coordinate location necessary.
I now need to prevent the ball being able to move through them.
Given that all my rotations and movements of the ball are relative to where it was last time, i don’t know how to get an exact opengl coordinate for where it is. If i could do this then i was proposing to pick 18 coordinates on its perimiter and test if these are within a margin(x) of any of the spheres that make up the walls.
Please help with any suggestions of how to get the balls actual coordinates and if you have any suggestions for better collision detection methods that would be much appreciated.
Could i even do a test to see if open gl is trying to draw an object (sphere) on top of another object (wall)?
thanks
Shaun

You said that the user controls the sphere, so you do know where the sphere is at all times. Right? There is no velocity/acceleration/gravity involved right? Then it is a simple check between the sphere coordinates + radius to the wall.
This is assuming 2D, since you do not mention which. If 3D, you basically do the same thing, but you have 1 more dimension to check.

Yes, i am in a 2d world. Unless i do trig claculations each time i move, to calculate a new position for the sphere from the orientation and distance moved, i don’t know of a command that will simply tell me the current location relative to the 0,0 that the sphere started at before all the translates and rotates.
is there such a command?

hi!
so you never know where your ball is, right?
depending on what key is pressed you move your ball in wanted direction - if i understand you right

it’s not good not to have stored your ball’s coordinates somewhere…you should have at least variables like
float position[3]
float angles[3]
and each time you want to move your ball you should change them
then each frame you should apply proper transformation (glRotate, glTranslate…) so your ball is in right place and you know where it is
have fun!

I thought that might be where we were heading and so implemented exactly that style system.
thanks
shaun