Bouncing off an angle with advanced coordinate rotation

This topic is 1146 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Let's say we have an angled line and a ball that is going to hit it from above...when hit is performed we use this matrix rotation or advanced coordinate rotation:

var x2:Number = cos * x1 - sin * y1;
var y2:Number = cos * y1 + sin * x1;

so we rotate counterclockwise the line to make it straight, lets say the line is at point (100, 100), the width of the line is also 100, and its at 45 degrees, according that the bottom are positive degrees and the top are negative, so the rotation from 45 to 0 is counterclockwise, this works if the ball hits the line from the right side, but what if the line is at 160 degrees, and the ball hits the line at the left side, in this case we can't rotate the line counterclockwise, cause the ball will be rotated too by this formula and the ball coordinates will be under the line in the cartesian plane and that is technically wrong, we have to rotate the line clockwise...

if you don't understand what I'am talking about, please see this chapter of the book..http://flylib.com/books/en/4.261.1.71/1/ - here it shows how the bounce if handled, but it does not explain how to do the same when the ball is at the left side from the point of where the line goes...

Edited by Kjelkor

Share on other sites

Yeah, just use a reflected vector..

I've made a GPU particle system with a depth+normal cubemap for collision, and just used

float 3 reflvec = reflect(direction, normal);

- works really great!

1. 1
2. 2
3. 3
Rutin
16
4. 4
JoeJ
13
5. 5

• 10
• 9
• 14
• 10
• 25
• Forum Statistics

• Total Topics
632646
• Total Posts
3007637
• Who's Online (See full list)

There are no registered users currently online

×