|
![](/i/fill.gif) |
"Andrew Coppin" <orp### [at] btinternet com> wrote in message
news:3fb53d4c$1@news.povray.org...
> ....
> And the biggy:
>
> #declare SA = sphere {<0, 0, 0>, 1}
> #declare SB = sphere {<+8, 0, 0>, 1}
>
> SA is stationary. SB is travelling along the X-axis. Since the two have
> equal mass (no, they do, cos it's my universe and I SAID SO :-), when SB
> hits SA, SB will come to a complete stop, and SA will continue on with
> (roughly?) the same velocity as SB had.
>
> How suppose we change the start conditions:
>
> #declare SA = sphere {<0, 0, 0>, 1}
> #declare SB = sphere {<+8, +0.2, 0>, 1}
>
> Unless I'm horribly mistaken, SB should bounce off SA at an angle (WHICH
> angle??), transferring only some (HOW MUCH?) of its momentum to SA.
>
> Anyone care to add details?
>
> Thanks.
> Andrew.
>
Andrew, you need to build two macro's out off the following theory:
1. Detect collision.
**********************************************************
The movement of a particle is given by:
s = s0 + v.t
The vector notation for particles A and B:
vecSa = vecA + vecVa.t
, with vecSa = position at time t,
vecA = position at time zero,
vecVa = velocity, so:
vecSb = vecB + vecVb.t
The distance between A and B is:
vecS = vecSa - vecSb
= (vecA + vecVa.t) - (vecB + vecVb.t)
= (vecA - vecB) + (vecVa - vecVb).t
= vecD + vecV .t
vecS = vecD + vecV.t
When there is collision then:
R = rA + rB = |vecS|
R^2 = vdot(vecS,vecS)
R^2 = vdot((vecD + vecV.t),(vecD + vecV.t))
this gives:
vdot(vecV,vecV).t^2 + 2.vdot(vecD,vecV).t
+ (vdot(vecD,vecD) - R^2) = 0
The Discriminant of this equation is:
Disc = 4.vdot(vecD,vecV)^2 - 4.vdot(vecV,vecV).(vdot(vecD,vecD)-R^2)
CollisionTimes:
t = _______________________________
2.vdot(vecV,vecV)
Eliminating the factor 2:
t = _______________________________
vdot(vecV,vecV)
The smallest time is:
-sqrt(D) - vdot(vecD,vecV)
t = _____________________________
vdot(vecV,vecV)
with:
D = vdot(vecD,vecV)^2 - vdot(vecV,vecV).(vdot(vecD,vecD)-R^2)
Condition for collision: D > 0 (if D = 0 they only touch each other)
If t < 0 then this was a collision in the past and you have to try the
other solution as well.
*********************************************************
2. Calculate new velocities if collision takes place.
*********************************************************
When 2 particles collide, they bounce from a plane perpendicular to their
distance vector vecD. The normal of this plane is the distance vector:
vecN = vecD.
The working lines of their velocities are given by vecVa_1 and vecVb_1
and will normally cross each other. We need to split these vectors in a
component along the normal and a component in the colliding plane.
(Make a 3D-drawing if you can't imagine this.)
Along the normal we need the speed of the particles (Speed is velocity
without the direction, so it is a scalar). This is given by:
Va_n_1 = vdot(vnormalize(vecN),vecVa_1)
Vb_n_1 = vdot(vnormalize(vecN),vecVb_1)
After the collision we get new speeds:
Va_n_2 and Vb_n_2
The new velocities are given by:
vecVa_2 = vecVa_1 - (Va_n_1 - Va_n_2).vnormalize(vecN)
vecVb_2 = vecVb_1 - (Vb_n_1 - Vb_n_2).vnormalize(vecN)
Collision :
Particle speeds:
Va_1 and Vb_1 (before)
Va_2 and Vb_2 (after)
Particle masses:
Ma and Mb
Reduced masses:
Equations to solve:
Ma.Va_1 + Mb.Vb_1 = Ma.Va_2 + Mb.Vb_2
Va_1 - Vb_1 = -e.(Va_2 - Vb_2)
For molecules: e = 1 (e = elasticity)
Answers for elasticity is 1:
In order to get a correct answer, we have to determine the relative
signs of Va_1 and Vb_1, that will say:
are they moving in the same or in the opposite direction along
the normal of collision. This is done automatically by
Vx_n_1 = vdot(vnormalize(vecN),vecVx_1), with x = a or b.
**********************************************************
You can count on the correctness of this theory, for I've used it in an
animation that I will place in p.b.a.
Succes with it,
Jaap Frank
Post a reply to this message
|
![](/i/fill.gif) |