Cpl.Bator wrote:do you plan to make a library ?
With easy control ?
ex : Make_Bouding_Box(x1,y1,w,l)

I have not such plan, because there is a big difference for real mechanic simulation (which should be fine faithful with the real world) and simulations for games, etc.
I think there is too hard besides of a nonsense to make a lib of funtions for real mechanics simulations for games and general programming. That lib should be good for technical and scientific purposes.
However, the function you mention is already done in the code (it is the heart of all the code)
Code: Select all
ParticleAndBarbellShock(l=0.1,R=0.65,W=0.91,m1=0.3411,m2=0.1411,V1=0.0,V2=0.0,e=1.0,K=/3.0)
where l is the lengh (from the barbell center) where the particle collides.
R is the half lenght of the barbell.
W is the omega (angular speed) at which the barbell is rotating before collision.
m1: mass of the particle
m2: mass of the barbell
V1: particle linear speed before collision
V2: barbell linear speed before collision (refered to the center of barbell, of course).
e is a constant from 0 to 1 which defines the features of the collision (1 => total elastic: no kinetic energy is transformed in the process; 0 => all the initial kinetic energy is transformed in deformation and heat, and objects don't bound, but after collision it remains stopped one respect to the other). The case of a 2 cars collision would be about an e=0.2 or so; and for billiards would be about e=0.99 . e=1 is an ideal situation.
K is a factor for the Inertial momentum; the factor depends on the geometry of the rotating object [1/3 for a barbell (considering its half-lenght as its radius), 1/3 for a rectangle (considering its half-diagonal as its radius), 1/2 for a disc, 2/5 for a sphere... etc. ].
NOTE that the function outputs the new omega after collision, the new V1 , and the new V2.
As said, that function is the heart of the code, but i had to translate a particle-barbell collision
to a particle-rectangle collision, that is: GoParticleAndBarbell(). And that's what really caused me hard pain and headache. But finally i did it.
EDIT: After all, besides of all, you need to tell to the box what are the items which will collide with it and what aren't; you need to detect the collision, which is easy but large; you should give certain properties for the collision to the box; etc.
Thus, you have the code, which is a good resource to do things
