2

I am creating a game where I want to determine the intersection of a single line. For example if I create a circle on the screen I want to determine when I have closed the circle and figure out the points that exist within the area.

Edit: Ok to clarify I am attempting to create a lasso in a game and I am attempting to figure out how I can tell if the lasso's loop is closed. Is there any nice algorithm for doing this? I heard that there is one but I have not found any references searching on my own.

Edit: Adding more detail

I am working with an array of points. These points happen to wrap around and close. I am trying to figure out a good way of testing for this.

Thanks for the help.

Thoughts?

Tone
  • 322
  • 1
  • 3
  • 16
  • Sorry, but your question is not very clear for me. Do you mean that you want to compute the intersection of a single line with several objects already drawn ? In that case, one solution is to compare objects not to compare each point of each object (it seems that you were talking about that, but I am not sure). For example, not determine if a circle cross a line, you compute the distance between the line and the center of the circle, and you compare with the radius of your circle. Can you detail your question ? – ThibThib Jun 29 '09 at 20:08
  • I agree. Try to be more specific about the nature of your problem. – rtn Jun 29 '09 at 20:27

1 Answers1

2

Your question has been addressed many times in the game development literature. It falls under the broad category of "collision detection." If you are interested in understanding the underlying algorithms, the field of computational geometry is what you want.

Game development books will also describe collision detection algorithms. One book of this sort is Game Physics by Eberly.

Community
  • 1
  • 1
user128807
  • 10,447
  • 17
  • 53
  • 72