Page 2 of 2

Re: A small coding question

Posted: Wed Jul 14, 2010 1:18 am
by xiphirx
Kyosaur wrote:
X Abstract X wrote:It's almost 8:00am now, my head is spinning in all these sketches I'm making, I'm probably overcomplicating this. I'm going to bed, I'll have another look tomorow. I'm pretty sure I have this all worked out if I can figure out how to calculate one angle that I'm missing.
Ok, keep me posted :D.

If you think it would be easier, i can change the area to a rectangular one (although if i do that, i lose my "bounce" affect, and will have to learn how to do basic physics :|).
Here's a thought from a math friend of mine: get the line from the player to the soccer ball, figure out where it intersects with the edge of the circle
(although if i do that, i lose my "bounce" affect, and will have to learn how to do basic physics :|)
You do know that the ball does not come back with the exact angle on a circle right?

Re: A small coding question

Posted: Wed Jul 14, 2010 2:04 am
by Ginto8
xiphirx wrote:Here's a thought from a math friend of mine: get the line from the player to the soccer ball, figure out where it intersects with the edge of the circle
ok I really haven't been following this thing at all, but I can help with the point of collision on the outside edge of the ball, if you have the centers and the radius.

Code: Select all

Vector dist = Player.center-Ball.center; // a line from the ball to the player
Point edgeCoord = (dist.normalized()*Ball.radius)+Ball.center;
all the .center's should be vectors or some comparable type. Vector::normalized() returns the normalized version of the vector, and the rest should be easy to figure out.