# Determine angle made by a ball inside a rectangle

#### rajeshmarndi

From the picture i.e attached. Can there be a formula, where the ball will strike after certain number of hit, say on side b, what will be the angle the ball will make after n successive hit.

I think it is just not possible, one can only measure the next angle the ball will make, provided one know the present position where the ball has hit.

Thank you.

#### Attachments

• 39.3 KB Views: 347

#### Simon Bridge

Homework Helper
You would need to know the velocity and position of the ball at some time, the rule followed by the bounce, and the dimensions of the box.

#### rajeshmarndi

You would need to know the velocity and position of the ball at some time, the rule followed by the bounce, and the dimensions of the box.
Sorry, my question was not clear, then. Its a rectangle board, where a ball or a striker keep on hitting the side of the wall, assuming no change in velocity. We could take an arbitrary position and velocity to start with.

#### Simon Bridge

Homework Helper
assuming no change in velocity
If the velocity does not change, then there is no bounce.

Recall, velocity is a vector: it is speed and direction. Do you mean that the speed is unchanged after rebound?
Then my comment still holds.

The direction determines the angle of the strike. You can see this from your diagram.
The angle of the rebound depends on the rules for the rebound - maybe the rebound angle is always equal to the strike (incident) angle, maybe not.
Whatever, you need to know the rule.

Technically, since a ball is round, it may also have some spin - which also needs to be known.

#### rajeshmarndi

Technically, since a ball is round, it may also have some spin - which also needs to be known.
I may be wrong again explaining. Just consider, its a computer game, where a line hits the wall of a rectangle(of any length and breadth). Speed of the line is not needed as we are only interested in knowing, at what angle the line will hit the side of the rectangle, after successive rebound. Or at what angle the line will hit a certain side, say side b, after n successive hit to side b.

We can start with say, the line originate from side a, at a certain position, say x distance from right corner and at an certain angle with side a, towards side b(just like in the picture).

#### Wayland Bugg

I thought you explained it fine. I may do some more on this but I attached some work to figure relevant coordinates based on initial position (p1) and initial angle (a) to n=3 terms for a rectangle 100Wx50H. This is my first whack at this and these are all unique terms so I don't think this is a practical solution.

#### Attachments

• 3.3 KB Views: 155
• 53.2 KB Views: 291
• 10.8 KB Views: 85

#### HallsofIvy

Homework Helper
It is possible to choose the initial position and direction of motion so that the ball contacts the sides of the square only at the midpoints. It is also possible to choose the initial position and direction of motion so that the ball will eventually hit the sides of the square at every point. So there is not going to be any simple answer to to your question.

#### Simon Bridge

Homework Helper
I may be wrong again explaining.
No - I get what you are saying - I'm just covering the bases.
Just consider, its a computer game, where a line hits the wall of a rectangle(of any length and breadth). Speed of the line is not needed as we are only interested in knowing, at what angle the line will hit the side of the rectangle, after successive rebound
Context is everything - it is a lot easier to get a good reply if you include what the solution is for.
You don't need the speed part of the velocity for the video game to determine the angle of the next bounce, but you do need the direction part of the velocity.
If you want to predict what happens on the nth bounce, then you need more information.

You will always need more information than that. So the answer to your original question:
Can there be a formula, where the ball will strike after certain number of hit, say on side b, what will be the angle the ball will make after n successive hit.
... the answer is "no" there is no formula for what you ask.

For the situation you seem to be thinking of, where the rebound rules are the same everywhere, then there are only 2 possible rebound angles.
The angle of the rebound depends, in this case, on the wall the "ball" rebounds from. You may be able to work this out from the number of rebounds... if you have the initial position and direction.

#### rajeshmarndi

You don't need the speed part of the velocity for the video game to determine the angle of the next bounce, but you do need the direction part of the velocity.
Say, the rectangle dimension is of 100Wx50H. The line originate from midpoint, side a(position), at an angle of 25 degree towards left(direction). From geometry, we can get the next hit position on side b of the rectangle. But it seem cannot give the position after nth rebound, with given initial position, direction and dimension of the rectangle.

For the situation you seem to be thinking of, where the rebound rules are the same everywhere, then there are only 2 possible rebound angles.
The angle of the rebound depends, in this case, on the wall the "ball" rebounds from.
I didn't get the need for rebound rules. The line rebound, just as if it is hitting a mirror. Consider the rectangle sides are mirror.

So the answer to your original question: ... the answer is "no" there is no formula for what you ask.
Context is everything - it is a lot easier to get a good reply if you include what the solution is for.
The reason for asking this question is, I see it similar to generation of prime number. Just like there isn't a formula for nth prime, because to get nth prime, we need to know all prime less than nth prime. We just cannot jump to nth prime, without considering previous primes. Similarly in this rebound game within the rectangle, we need the previous hit location, and direction to find the nth hit position on the sides of the rectangle.
If in the computer game, the computer has to show the location after nth rebound, it has to calculate for each rebound to show the nth hit position.

#### Simon Bridge

Homework Helper
It is not even remotely similar to getting prime numbers.

You started with a problem that was under-specified, that's all.
Once you know the things I told you, you can work out the angle of the nth hit without calculating any of the others first.

#### LCKurtz

Homework Helper
Gold Member
It is not even remotely similar to getting prime numbers.

You started with a problem that was under-specified, that's all.
Once you know the things I told you, you can work out the angle of the nth hit without calculating any of the others first.
Are you saying that given a rectangle with sides $a$ and $b$, an initial position $(c,d)$ and direction $\theta$, and assuming mirror image reflection, you can calculate the angle of the $n$th hit in terms of $a,~b,~c,~d,~\theta$? In principle? In practice? I am quite skeptical. I would expect numerous and complicated cases depending on the aspect ratio of the rectangle and the starting data, even if you had specific numbers for the variables to begin with. Not to mention not calculating the preceding values.

#### .Scott

Homework Helper
From the picture i.e attached. Can there be a formula, where the ball will strike after certain number of hit, say on side b, what will be the angle the ball will make after n successive hit.

I think it is just not possible, one can only measure the next angle the ball will make, provided one know the present position where the ball has hit.

Thank you.
There are formulas for everything you want, given the initial position, direction, and the dimensions of the rectangle.
To make things simpler, instead of having a grid that is WxH in size, set up a matrix where every cell is the size of the rectangle.
Now, instead on bouncing, the ball simply crosses from one cell to another. If it starts by moving to the left, the first time it crosses a vertical line it will correspond to side B and then it will switch back and forth between B and D. Similarly for moving right, up, and down. Every time is crosses a horizontal line, the cell will correspond to a mirror image of the previous cell - switched top-to-bottom. For a vertical line - switch left to right.

Since the B-side vs D-side switches every other time, and crossing a vertical line causes the polarity to switch every other time, crossing vertical lines will not cause the angle at B to change. On the other hand, every time it crosses a horizontal line, the angle will switch.

So let's say that the ball starts along the bottom of the HxW rectangle from a point that is X from the bottom left corner where 0<=X<=1 and 0 is the left corner and Y is the right corner. Then, it strikes the left side at a point that is Y from the bottom left corner where 0<=Y<=1. So, on the first bounce, it will strike side B at an angle of S=atan(HY/WX). On subsequent bounces it will strike at either +S or -S.

On the Nth bounce, it will have travelled horizontally W(2(N-1)+X) and vertically H(Y/X)(2(N-1)+X). The number of horizontal lines it would have crossed would be that vertical distance divided by the height and truncated to an integer: Int((Y/X)(2(N-1)+X)).
Since the angle will flip that number of times, we will take modulo 2 and generate the sign of the angle from that:

atan(HY/WX) (1-2(Mod2(Int((Y/X)(2(N-1)+X)))))