NTNUJAVA Virtual Physics LaboratoryEnjoy the fun of physics with simulations! Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
November 01, 2020, 07:56:22 am

Life is an inspiration. ..."Mahatma Gandhi(1869-1984, The greatest leader of modern India)"

 Pages: [1]   Go Down
 Author Topic: How to detect that the objects are just touching each other, and set the dv/dt=0  (Read 4964 times) 0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
lookang
Hero Member

Offline

Posts: 1796

http://weelookang.blogspot.com

 « Embed this message on: June 21, 2010, 09:59:21 pm »

How to detect that the objects are just touching each other, and set the dv/dt =0?

i realised the new evolution event codes help to achieve the time to go on which answers the question i posted earlier on.
the code is
Code:

if (v>0) return x+carSize/2-xbumperbottom; // bounced at x=xmax
else if(v<0)return x-carSize/2-xbumpertop; // bounced at x=xmin or x+carSize/2
return 1.0;
//return 1.0;

action
Code:

v=-e*v;

thx!
thx!

but now, if e=0.1 to 0.9
the car will move beyond the bummer at the bottom if the velocity is low.

what is the elegant way to overcome this new problem?
thx!

oh another problem e=0, it doesn't move at all due to v=0 at start.

if i use wolfgang's and paco evolution codes, it solves the problems above, but time stops running when they car is stationary against the bummer.
any way to make time continue?
 evolution.png (36.22 KB, 603x632 - viewed 440 times.) « Last Edit: June 21, 2010, 10:25:19 pm by lookang » Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3086

 « Embed this message Reply #1 on: June 21, 2010, 10:46:12 pm » posted from:Taipei,T\'ai-pei,Taiwan

There are infinite value in number system (mathematical point of view), but computer has finite memory.
So the computation always has numerical error.
That is the reason why there is a error range when you set up the event.
If the difference in event checking is less than the error range, it is assume to be the same.

Because your object starts at one end, so the condition is match in the beginning (unless you also add velocity checking condition).

If e=0 , then the bouncing speed is zero. How would you expect the object to move???
For e<1: the velocity will decrease by the same ratio with each collision.
Eventually, it will reach near zero and the event condition will match all the time.
So more code is needed to take care of it.
Physically, the object is stopped when the velocity is smaller than experimental error.
And no one can notice the differences when the moving is less than the resolution of the computer screen resolution.

You should pause the simulation when the object is very close to one of the event position and the velocity is less than some minimum value.
More calculation is useless.
 Logged
lookang
Hero Member

Offline

Posts: 1796

http://weelookang.blogspot.com

 « Embed this message Reply #2 on: June 29, 2010, 02:44:28 pm » posted from:Singapore,,Singapore

the solution to this problem has been solved here
http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1841.0

hope this info helps someone too
 Logged
 Pages: [1]   Go Up
Life is an inspiration. ..."Mahatma Gandhi(1869-1984, The greatest leader of modern India)"