|
|
|
 |

September 12th, 2003, 08:07 PM
|
 |
Shrapnel Fanatic
|
|
Join Date: Mar 2003
Location: CHEESE!
Posts: 10,009
Thanks: 0
Thanked 7 Times in 1 Post
|
|
OT: would anyone happen to know how to calculate bouncing a ball off an angled box?
would anyone happen to know how to calculate bouncing a ball off an angled box?
[ September 12, 2003, 19:08: Message edited by: narf poit chez BOOM ]
__________________
If I only could remember half the things I'd forgot, that would be a lot of stuff, I think - I don't know; I forgot!
A* E* Se! Gd! $-- C-^- Ai** M-- S? Ss---- RA Pw? Fq Bb++@ Tcp? L++++
Some of my webcomics. I've got 400+ webcomics at Last count, some dead.
Sig updated to remove non-working links.
|

September 12th, 2003, 08:21 PM
|
 |
Captain
|
|
Join Date: Oct 2002
Location: Brazil
Posts: 827
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: OT: would anyone happen to know how to calculate bouncing a ball off an angled box?
Possibly, but I need more details.
__________________
Have you ever had... the sudden feeling... that God is out to GET YOU?
Well, my girl dumped me and I'm stuck with the raftmates from Hell in the middle of the sea and... what was the question again???
|

September 12th, 2003, 08:38 PM
|
 |
Shrapnel Fanatic
|
|
Join Date: Mar 2003
Location: CHEESE!
Posts: 10,009
Thanks: 0
Thanked 7 Times in 1 Post
|
|
Re: OT: would anyone happen to know how to calculate bouncing a ball off an angled box?
ok, right now what i've got is a 3d setup, but i'm only using the x and z planes. i generate a ball at the bottom-left corner of the screen and send it at an angle from 0-90 into a bunch of boxes. the boxes are currenty square and not angled, but what i want is to randomly shoot in balls from all sides of the screen and have them bounce off rectangular boxes.
__________________
If I only could remember half the things I'd forgot, that would be a lot of stuff, I think - I don't know; I forgot!
A* E* Se! Gd! $-- C-^- Ai** M-- S? Ss---- RA Pw? Fq Bb++@ Tcp? L++++
Some of my webcomics. I've got 400+ webcomics at Last count, some dead.
Sig updated to remove non-working links.
|

September 12th, 2003, 08:49 PM
|
 |
Captain
|
|
Join Date: Oct 2002
Location: Brazil
Posts: 827
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: OT: would anyone happen to know how to calculate bouncing a ball off an angled box?
Easy, the incoming and outgoing angles are always equal. I can make a drawing when I get home, but for now imagine an underlined V. The underline is the box surface and the V is the ball's trajectory. Now the angle from the left side of the underline to the left of the V must be equal to the angle from the right side of the underline to the right side of the V.
This in 2-D, which is what you are using, right ?
__________________
Have you ever had... the sudden feeling... that God is out to GET YOU?
Well, my girl dumped me and I'm stuck with the raftmates from Hell in the middle of the sea and... what was the question again???
|

September 12th, 2003, 08:58 PM
|
 |
General
|
|
Join Date: Sep 2003
Location: United Kingdom
Posts: 3,603
Thanks: 0
Thanked 22 Times in 22 Posts
|
|
Re: OT: would anyone happen to know how to calculate bouncing a ball off an angled box?
*Looks at the thread* *Runs away in terror* Please, Narf, you could add a warning in the title for the ones like me who have issues with this kind of... things. 
|

September 12th, 2003, 09:10 PM
|
 |
Shrapnel Fanatic
|
|
Join Date: Mar 2003
Location: CHEESE!
Posts: 10,009
Thanks: 0
Thanked 7 Times in 1 Post
|
|
Re: OT: would anyone happen to know how to calculate bouncing a ball off an angled box?
well, the objects are 3d, but it's on a flat plane.
ok, so i figure out what angle the wall is at, then:
wall at 45 degrees, ball comming in at 90, 45-90=-45, 45+-45=0. ball coming in at 270, 45-270=-225, so, if negative 360+-225=135? doesn't work there. but, since it's hitting the bottom...angle at 225, same tilt, 225-270=-45, 225--45=270. doesn't work.
i missed something, right?
what more warning do you want?
__________________
If I only could remember half the things I'd forgot, that would be a lot of stuff, I think - I don't know; I forgot!
A* E* Se! Gd! $-- C-^- Ai** M-- S? Ss---- RA Pw? Fq Bb++@ Tcp? L++++
Some of my webcomics. I've got 400+ webcomics at Last count, some dead.
Sig updated to remove non-working links.
|

September 12th, 2003, 11:27 PM
|
 |
Shrapnel Fanatic
|
|
Join Date: Feb 2001
Location: Waterloo, Ontario, Canada
Posts: 11,451
Thanks: 1
Thanked 4 Times in 4 Posts
|
|
Re: OT: would anyone happen to know how to calculate bouncing a ball off an angled box?
Neglecting corner hits;
1) You want to know the relative angles between wall and ball. All arithmetic is modulo 360 degrees. (359 + 1 = 0)
2) We can rotate the coordinates by minus the wall angle. This makes the wall look like zero, and the ball will be ball_angle - wall_angle.
You want to reflect in the plane of the wall.
Taking 90 degrees off it, then taking the negative, and adding the 90 degrees back.
85-90 =-5, -5 -> +5, 5+90 = 95 (check)
224 -90 = 134, 134 -> -134 (or 226), 226+90 = 316 (check)
3) Restore the original coordinates by adding back the wall's angle.
So:
NEW_ANGLE = ((((OLD_ANGLE-90-WALL_ANGLE)*-1)+90+WALL_ANGLE) +360) % 360
Where % = modulo operator in whatever programming language you use.
360 is added before the modulo operation because to ensure the resulting value is positive. (Some programming Languages deal with modulo of negative numbers differently)
-----
For Corner Hits:
The effective plane that the ball is bouncing off of is perpendicular to the line connecting the center of the ball to the corner.
__________________
Things you want:
|

September 12th, 2003, 11:36 PM
|
 |
Captain
|
|
Join Date: Oct 2002
Location: Brazil
Posts: 827
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: OT: would anyone happen to know how to calculate bouncing a ball off an angled box?
OK, I can explain this to you for one simple situation and you'll have to work it out for the rest.
Let's say that the ball travels along the X-axis, therefore its trajectory is at 0 degrees (at 90 degrees it would be going 'up' the Y-axis). And let's say further that the wall it's going to bounce off of intercepts the X-axis at some point.
OK, now we are going to measure the wall's angle of inclination starting at the X-axis and ending at the wall's 'upper' segment. This angle is therefore being measured in a counter-clockwise direction. Let's call its value A.
Since the ball's trajectory is at 0 degrees, the angle between it and the lower segment of the wall is also equal to the wall's inclination, A. Now it's going to rebound at an angle to the wall's upper segment that is equal to this inclination, therefore to the X-axis itself it is an angle of 2A.
Some examples : Wall at 45 degrees - ball rebounds at 90 degrees (goes up).
Wall at 30 degrees - ball rebounds at 60 degrees.
Wall at 90 degrees - ball rebounds at 180 degrees (trajectory doubles back on itself).
Wall at 135 degrees - ball rebounds at 270 degrees.
The trick is, A is always between 0 and 180; outside these bounds the wall has 'flipped over' and you still have A between 0 and 180.
That's the best I can do from here. I'm not too good at explaining things without drawing lots of diagrams.
__________________
Have you ever had... the sudden feeling... that God is out to GET YOU?
Well, my girl dumped me and I'm stuck with the raftmates from Hell in the middle of the sea and... what was the question again???
|

September 13th, 2003, 12:57 AM
|
 |
Shrapnel Fanatic
|
|
Join Date: Mar 2003
Location: CHEESE!
Posts: 10,009
Thanks: 0
Thanked 7 Times in 1 Post
|
|
Re: OT: would anyone happen to know how to calculate bouncing a ball off an angled box?
thanks to the both of you.
that's for making sure it's still between 0-360, right?
anyone know how to figure out what side it hit when the box is rotated? i've got an idea, but it's clunky, rotating the whole thing, ball and box, back to 0 while keeping there relative positions and then back.
[ September 13, 2003, 00:36: Message edited by: narf poit chez BOOM ]
__________________
If I only could remember half the things I'd forgot, that would be a lot of stuff, I think - I don't know; I forgot!
A* E* Se! Gd! $-- C-^- Ai** M-- S? Ss---- RA Pw? Fq Bb++@ Tcp? L++++
Some of my webcomics. I've got 400+ webcomics at Last count, some dead.
Sig updated to remove non-working links.
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is On
|
|
|
|
|