[Trigger]Ball Bounce

Status
Not open for further replies.

Gost

Level 10
I am making a ping pong mini game and am having trouble with the right bounce calculations. (Refer to my attachment) The wall is actualy a region, when a ball enters it i want to know how i would calculate the angle between the wall and the facing of the ball (angle a), and then make it so when the ball bounces off (angle b) it is the same angle.

So im looking for a bounce...formula... help lol.
Sorry for the messy explanation the idea is kinda jumbled.

Attachments

• Explanation.jpg
4.3 KB · Views: 271

GhostWolf

Level 29
The angle should simply be the opposite of a (-a).
If for example the angle is 45, then it would bounce in -45.

PurplePoot

Level 40
The angle should simply be the opposite of a (-a).
If for example the angle is 45, then it would bounce in -45.
It should actually be 180-a, relative to the surface, as far as I can tell. -a works in some situations but not always.

Gost

Level 10
I'll try it out, lame i knew it would be something ridiculously simple.

Edit: Actually, in addition how would i find out the measure of angle a?

Double Edit: I'm retarded, i got it working now thanks both of you!

PurplePoot

Level 40
Note about GhostWolf's post, it's -a relative to the normal.

Volvox

Level 15
With a being the facing of the ball, the angle should be a + (180 + 2a) because a and b must always be equal. Then you 'rotate' a for 180 degrees into the wall and add 2 more a, 1 to 'rotate' a into the wall and another to set it to b. This should work fine.

PurplePoot

Level 40
That doesn't make sense, since 180 degrees is the maximum distance between the two angles, and this would produce a difference of 180+2a, which is larger for a>0 (Which is especially flawed because the other angle should be getting smaller as a gets bigger, not the other way around!)

Saishy

Level 12
That doesn't make sense, since 180 degrees is the maximum distance between the two angles, and this would produce a difference of 180+2a, which is larger for a>0 (Which is especially flawed because the other angle should be getting smaller as a gets bigger, not the other way around!)
No, B gets bigger if A gets bigger.
If not you throw the ball in a 90º angle and it bounces 0º in the direction of the wall... Lol

Volvox

Level 15
PurplePoot, it's basic vector physics... I go in a math/physics/chemistry/and-all-science-stuff high school(don't know how you call it, please tell me), we study things like that and i can assure you, this works fine.

GhostWolf

Level 29
It fails for 90 and 270 (it returns the same angle) :/

Volvox

Level 15
Because this is meant to go with a perpendicular wall(north-south) so theoretically, it is not a fault because from those angles, you couldn't really hit the wall.

PurplePoot

Level 40
PurplePoot, it's basic vector physics... I go in a math/physics/chemistry/and-all-science-stuff high school(don't know how you call it, please tell me), we study things like that and i can assure you, this works fine.
Display it with a diagram, then, because I assume you are making very specific assumptions as to where the angle is measured from, etc, that you are not providing (Note that you didn't even comment on my point, you just said you were right and I was wrong without providing any evidence).

donut3.5

Level 27
If it hits either side, it should be 180 - angle, if it his a top or bottom boundary, it should be 360 - angle.
--donut3.5--

Need_O2

Level 19
h4x use a System for that

PurplePoot

Level 40
BerZeKer, judging by that diagram you provided,

Assuming the wall is horizontal,

Take 10 degrees.

a = 10

The new angle is (a + (180 + 2a)) = (3a + 180)

3(10) + 180 = 30 + 180 = 210

So balls pass through walls now?

It should be (a + (180 - 2a)) = (180 - a), which is what I suggested in the first place.

(Calculations) --

180 - a = r (angle of reflection)
180 - 10 = r
170 = r

And something rather ironic, the only angles this actually works for are those which Volvox criticized because they are impossible angles of incidence. (0 and 180)

Last edited:

Volvox

Level 15
Lol, true. I am sorry, i expressed my formula awkwardly. Very awkwardly. What i meant is displayed in the picture below. In that case, the angle would equal facing of the ball + 180 + 2 alpha.

Attachments

• angles.jpg
5.5 KB · Views: 129

PurplePoot

Level 40
Since angles go Counterclockwise, that's minus 2a, and thus 180 - a.

Volvox

Level 15
Counterclockwise you say. I am one stupid child, you know. Sorry, too much mathematics today. Counterclockwise, i'll remember that. Sorry once again, i hope you understood what i meant.

HINDYhat

Level 20
Why are you using angles in the first place? Vector components FTW. Alot easier to work with and alot more efficient.

PurplePoot

Level 40
Well, seeing as it's GUI, there are a lot of things that don't make sense >>

I assume for ease of use, since that's the point of GUI anyways.

Volvox

Level 15
Hehe, gui sucks indeed... And shouldn't it be 180 - 2a? I have a tendency of being wrong lately but it seems more logical. There is also a problem with finding a if we do not know the wall's facing but that shouldn't be a big one.

PurplePoot

Level 40
It's `a + 180 - 2a = 180 - a`.

And if you know the orientation of the surface, the orientation of the angle is just relative to that surface, thus imagining the surface is flat and the ball is coming from a fixed side. (For example, the top, so that the range 0-180 is used)

GhostWolf

Level 29
Well, there isn't any magic quotation. All of them fail with 2 numbers (either 0 and 180 or 90 and 270).

Just use any of them and if you need a "bugged" number add a condition that checks if its that number.

PurplePoot

Level 40
GhostWolf, 180-a doesn't fail with any numbers.

Status
Not open for further replies.

[Trigger] Bouncing Ball?
Replies
2
Views
638
Replies
6
Views
1K
Replies
4
Views
577
[JASS] Bounce!
Replies
8
Views
1K
Replies
1
Views
608