10-21-2003, 03:28 AM
I became intrested in understanding how balls bounce when i downloaded your demo.. I read your comments and check Hugo Elias for a tutorial but i won't be happy just because i can do it by copying your code.. I wanna understand how it works and why some calculations are there..
balls(0).xv = COS(balls(0).angle * PI / 180) * balls(0).speed
balls(0).yv = SIN(balls(0).angle * PI / 180) * balls(0).speed
ok, here you split the direction and speed in to two vectors, that i understand..
impactx! = balls(1).xv - balls(0).xv
impacty! = balls(1).yv - balls(0).yv
then you calculate the resulting "force", now the things i don't understand begings..
what do you do when you normalize and what do you do when you returns the dot product between 2 vectors??
can you or somebody else be kind and explain why and what you are doing..
and also the following lines
impulsex! = impulsex! * ImpactSpeed! * balls(0).mass * balls(1).mass / 2
impulsey! = impulsey! * ImpactSpeed! * balls(0).mass * balls(1).mass / 2
xva! = balls(0).xv + impulsex! / balls(0).mass
yva! = balls(0).yv + impulsey! / balls(0).mass
xvb! = balls(1).xv - impulsex! / balls(1).mass
yvb! = balls(1).yv - impulsey! / balls(1).mass
Rel's code can be found at http://forum.qbasicnews.com/viewtopic.php?t=3408
Hope you find some time to explain it to me =)
thx!
balls(0).xv = COS(balls(0).angle * PI / 180) * balls(0).speed
balls(0).yv = SIN(balls(0).angle * PI / 180) * balls(0).speed
ok, here you split the direction and speed in to two vectors, that i understand..
impactx! = balls(1).xv - balls(0).xv
impacty! = balls(1).yv - balls(0).yv
then you calculate the resulting "force", now the things i don't understand begings..
what do you do when you normalize and what do you do when you returns the dot product between 2 vectors??
can you or somebody else be kind and explain why and what you are doing..
and also the following lines
impulsex! = impulsex! * ImpactSpeed! * balls(0).mass * balls(1).mass / 2
impulsey! = impulsey! * ImpactSpeed! * balls(0).mass * balls(1).mass / 2
xva! = balls(0).xv + impulsex! / balls(0).mass
yva! = balls(0).yv + impulsey! / balls(0).mass
xvb! = balls(1).xv - impulsex! / balls(1).mass
yvb! = balls(1).yv - impulsey! / balls(1).mass
Rel's code can be found at http://forum.qbasicnews.com/viewtopic.php?t=3408
Hope you find some time to explain it to me =)
thx!
ttp://hem.passagen.se/qb.basta