# Homework Help: Ricochet of moving / rotating block off a wall

1. Oct 16, 2012

### DigitalPenman

The title pretty much says it all. I'm looking to write a 2D physics sim in which various objects can bounce off solid surfaces (without gravity). The objects are rotating and translating at a constant rate. We are dealing only with x and y - not z.

Let's take a rectangular block with these data:
mass = 'm'
width = 'w'
height = 'h'
center = 'cx, cy' (simply w/2, h/2)
rot = 'θ' (around the origin cx,cy in degrees)
slope = 'sx', 'sy' (speed and direction of travel)

say one corner of this rectangle is x0, y0 just before the point of impact. What formula could describe this scenario where x1, y1 is the same corner during impact?
i.e. x1 = ...
y1 = ...
Please feel free to fill in any missing data that I may need.

2. Oct 17, 2012

### Staff: Mentor

I don't understand that question.

Here are some hints:
Momentum is conserved.
Angular momentum around the point of collision is conserved.
Neglecting friction, momentum transfer will occur perpendicular to the surface only.
Do you have elastic collisions? If yes, energy is conserved.

3. Oct 17, 2012

### DigitalPenman

I understand that elasticity in the objects is a factor. Let us simply assume that the wall has elasticity 'We' and the object has an elasticity 'Oe'.

If the object is in motion i.e. every point on the object is incremented by x = 'sx' and y = 'sy' and then the object rotates around its center point (cx, cy) by a rotation of θ, this can be defined by:

x' = cx + (x - cx)cosθ + (y - cy)sinθ + sx
y' = cy + (y - cy)cosθ - (x - cx)sinθ + sy

Any arbitrary x,y point on the rectangle is rotated and translated with this formula which works fine. My problems is when this object hits a wall and new values for θ, sx and sy must be computed.

4. Oct 17, 2012

### Staff: Mentor

Are you sure that you want to use elastic materials? That will complicate the required computations a lot.

See my previous post.

And in addition to the current angle θ, you need an angular velocity.

5. Oct 17, 2012

### DigitalPenman

I guess I shouldn't say elasticity. Basically, any minimal complexity variable so that the object can ricochet off the wall and not just stop when it hits the wall. I guess a good way to put it would be a solid object ricocheting off a solid wall in 2D space with no gravity.

Sorry, I forgot to say that the angle θ is actually incremented by an angular velocity 'av'. in a prior step. also, sx, sy would have to be incremented by some value on each step or the object wouldn't move say sx0, sy0. The whole thing would be:

loop{
θ = θ + av

x' = cx + (x - cx)cosθ + (y - cy)sinθ + sx
y' = cy + (y - cy)cosθ - (x - cx)sinθ + sy

sx = sx + sx0
sy = sy + sy0
}

6. Oct 17, 2012

### bigfooted

Elasticity is not what you think it is. It is just conservation of momentum you're interested in. elasticity will deform the object and it's nonconserving, so in the end your objects will stop moving.

When a solid square with known translational and angular velocity hits a wall with one of it's corners, then use the conservation equations to calculate the new angular and translational velocity. Just draw a free body diagram for this situation for a better understanding.

7. Oct 17, 2012

### DigitalPenman

Wow, thanks a million! The application seems to simulate the new rotation after the collision very naturally now.

Please see if this can be confirmed:

L = r x p for angular velocity, in my case:

r = (r1,r2) ==> (r1, r2) being the vector from the center (cx, cy) of the object to the point which has collided with the wall: x,y.
r1 = cx - x and r2 = cy - y.

p = mv which in my case is the vector p = (p1,p2) where p1 = m(sx), p2 = m(sy). sx and sy define the velocity of the object. I simply use an arbitrary mass of m which I added as an extra specification for an object.

so L = new rotation = r x p would be

L = new rotation = (cx - x)(m(sy)) - (cy-y)(m(sx)) using the cross product.

8. Oct 21, 2012

### bigfooted

Be aware that your approach is an approximation. It is not suited for the case where objects turn around their own center. For instance, you can use it for the rotation of the earth around the sun, but not for the rotation of the earth around its own axis.
Then you should use
L = Iw,
with I the moment of inertia and w the angular velocity.
Of course, some simple tests (first with angular velocity zero) can show you that your simulation works. Always try to find a case with a known solution that you can simulate.