NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Easy Java Simulations (2001- ) => misc => Topic started by: Fu-Kwun Hwang on September 03, 2009, 06:30:55 pm



Title: Another Cliper
Post by: Fu-Kwun Hwang on September 03, 2009, 06:30:55 pm
The following is a cliper simulation.
You can change the width of the blue object or the diameter of the green object
(click diameter to show the object and measure it's diameter).
[ejsapplet]

You may want to view the following video [youtube=kTLhmptHAPc]





Title: Re: Another Cliper
Post by: lookang on September 04, 2009, 05:08:17 pm
Hi Prof,

i been exploring the codes here for embedding the "blue object" into another vernier calipers applet.

i am puzzled how u make the blue object push the right internal jaw on both move together.

i can't locate the code for that "behavior".

chance to advise? thanks!

reference your codes under fixed constraints:
Code:
if(ox < oxmin+w/2)ox=oxmin+w/2;
else if(ox > x+w)ox=x+w;

if(oy>oymax)oy=oymax;


if(topone){
 if(x-x1>b)x=x1+b+0.2;
 px[2]=px[1]=x0+2*a+b;
 px[3]=px[4]=x0+a+b;
}

xdmin = ox+d+w/2;
if(oy > oymin && x < xdmin) x=xdmin;
if(x < x1)x=x1;
else if(x > x2)x = x2;



value=(x-x1)/ratio-0.05;





and the blue object has no code ON DRAG;

how is "the blue object push the right internal jaw on both move together" done?


Title: Re: Another Caliper
Post by: lookang on September 04, 2009, 05:21:28 pm
sorry i found it, no worries.

"if(oy > oymin && x < xdmin) x=xdmin;"

i will ask when need again.

quite a challenging task to do remixing alone. ;D