iDevGames Forums
2D reflecting a point off a circle - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: 2D reflecting a point off a circle (/thread-6157.html)



2D reflecting a point off a circle - Joseph Duchesne - Oct 23, 2004 02:23 PM

I need a function to reflect off a circle at the point of impact.

Here's the basic way I want it to work:
Code:
void reflect(float AngleBetweenCircleAndPoint, float *PointMovementAngle)
{
  //calculate stuffs here
  PointMovementAngle=TheEndResult;
  return;
}
I can also use the x and y position of both the point of the circle and point as well as their speeds. Anyone?
Thanks.


2D reflecting a point off a circle - MattDiamond - Oct 23, 2004 08:05 PM

Basic idea is to think of a line CP from the center of the circle to the point of impact P. Then compute the angle that the inbound ray makes with that line at P. Then reflect that angle around the line CP.

Sorry, I don't have code handy but this has come up on the forums before, so you should be able to get code for it that way. (Though the code examples I remember were using vector math.)