NTNUJAVA Virtual Physics LaboratoryEnjoy the fun of physics with simulations! Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
January 29, 2020, 11:04:50 am

"It is not the strongest of the species that survive, but the one most responsive to change." ..."Darwin(1809-1882, English naturalist Evolution)"

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

Offline

Posts: 1793

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 399 times.) « Last Edit: June 21, 2010, 10:25:19 pm by lookang » Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « 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: 1793

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
"It is not the strongest of the species that survive, but the one most responsive to change." ..."Darwin(1809-1882, English naturalist Evolution)"

 Related Topics Subject Started by Replies Views Last post About crashing objects in physlet Question related to Physics or physics related simulation jorgenio1 5 9928 January 28, 2015, 01:38:10 pm by Heihachi07 cylinder touching wall Question related to Physics or physics related simulation pradeep123 1 7554 December 31, 2008, 09:48:12 pm by Fu-Kwun Hwang how to make the logic to detect 12 or 12.00 when the answer is 12.0? Questions related to EJS lookang 6 9978 November 18, 2009, 07:40:31 pm by lookang how to detect a point is inside an area that is rotatable by cta ? Questions related to EJS lookang 2 5369 April 22, 2010, 10:25:02 pm by lookang view alternating objects illusion Fu-Kwun Hwang 2 31491 October 21, 2015, 01:39:22 pm by freddygon
Page created in 0.053 seconds with 22 queries.since 2011/06/15