NTNUJAVA Virtual Physics LaboratoryEnjoy the fun of physics with simulations! Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
September 24, 2020, 04:01:05 pm

Everything has its beauty but not every one sees it. ...Confucius (551-479 BC)

 Pages: [1]   Go Down
 Author Topic: how to make the left right button to vary x? for all modes  (Read 9894 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 02, 2009, 07:11:41 pm » posted from:Singapore,,Singapore

hi prof

currently, the left n right button works for mode singapore

code
action:
x=x+0.25714; right
and
x=x-0.25714; left

i need some tips on a generalized code for the other modes

attached in my attempt

Code:
if(mode.equals("0.02 mm version 1")){
dycst=1.;
n2s=51;
dx2=49*dxm/50;
nmode=5;
L=50*dxm+size;
// l_unit="0.02mm";
unit=0.02;
}else if(mode.equals("0.1 mm version 1")){
dycst=0.;
n2s=51;
dx2=49*dxm/50;
nmode=5;
L=50*dxm+size;
// l_unit="0.1mm";
unit=0.1;
}else if(mode.equals("0.05 mm version 1 singapore schools")){
dx2=39*dxm/40*2; //
n2s=21; // number of intervals on the lower scale
dycst=1.; //
nmode=2; //
L=40*dxm+size;
// l_unit="0.05mm";
unit=0.05;
}else if(mode.equals("0.1 mm version 2")){
dx2=39*dxm/40*2;
n2s=21;
dycst=0.;
nmode=2;
L=40*dxm+size;
// l_unit="0.1mm";
unit=0.1;
}else if(mode.equals("0.05 mm version 2")){
dx2=19*dxm/20;
n2s=21;
dycst=1.;
nmode=2;
L=20*dxm+size;
// l_unit="0.05mm";
unit=0.05;
}else if(mode.equals("0.1 mm version 3")){
dx2=19*dxm/20;
n2s=21;
dycst=0.;
nmode=2;
L=20*dxm+size;
// l_unit="0.1mm";
unit=0.1;
}
l_unit=unit+"mm";
x6[4]=x6[5]=x2+L;

i will try to figure out asap.

Embed a running copy of this simulation

Embed a running copy link(show simulation in a popuped window)
Full screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
• Please feel free to post your ideas about how to use the simulation for better teaching and learning.
• Post questions to be asked to help students to think, to explore.
• Upload worksheets as attached files to share with more users.
Let's work together. We can help more users understand physics conceptually and enjoy the fun of learning physics!
 *** There are 1 more attached files. You need to login to acces it! « Last Edit: June 02, 2009, 07:13:20 pm by lookang » Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #1 on: June 02, 2009, 07:25:13 pm » posted from:Taipei,T\'ai-pei,Taiwan

1.  dycst=0; no minor ticks. dycst=1; draw minus ticks.
The length of the ticks are evated by dycst*minor_ticke_length.
2. 0.02mm case without minor ticks will be the same as 0.1mm case. That is why all the rest parameters are the same.
3. n2s is the number of ticks on the scale.
 Logged
lookang
Hero Member

Offline

Posts: 1796

http://weelookang.blogspot.com

 « Embed this message Reply #2 on: June 02, 2009, 10:35:43 pm » posted from:Singapore,,Singapore

i think i figure out a way! critical thinking from thinking whole day LOL.
thanks!

will report finding asap
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #3 on: June 03, 2009, 09:08:15 am » posted from:Taipei,T\'ai-pei,Taiwan

The code you wrote was:
x=x-0.25718;// take 257.16 divide 50 mm divide 20

which is equal to x=x-dxm/20.;  for your case (20 smaller division).
 Logged
lookang
Hero Member

Offline

Posts: 1796

http://weelookang.blogspot.com

 « Embed this message Reply #4 on: June 03, 2009, 11:11:15 am » posted from:,,Singapore

i am making a super applet from remixing yours, thanks for code
x=x-dxm/20.; // for your case (20 smaller division).

just the right tip i need to make sense. Thanks!
 Logged
lookang
Hero Member

Offline

Posts: 1796

http://weelookang.blogspot.com

 « Embed this message Reply #5 on: June 03, 2009, 07:56:58 pm » posted from:Singapore,,Singapore

in the left button

if(x<=0){
x=0;
}
else {
x=x-increment;
}

initialization
increment = dxm/(1/unit);

it work beautifully, and i even added scaffolds to suggest the relationship

if ( error == 0 ) {
l_x="d="+l_x;
}
else if ( vs*unit+(-error*unit) >= 1 ){
l_x="d=" + dvalue((int)(x/dxm-1),unit)+ "+" +dvalue(vs*unit,unit)+ "+(" + dvalue(-error*unit,(unit))+ ") = " + l_x;
// l_x="d=" + dvalue((int)(x/dxm-1),unit)+ "+" +dvalue(vs*unit,unit)+ "+(" + dvalue(-error*unit,(unit)) + ")+ "=" ;
}
else if ( vs*unit+(-error*unit) <= 0 ){
l_x="d=" + dvalue((int)(x/dxm+1),unit)+ "+" +dvalue(vs*unit,unit)+ "+(" + dvalue(-error*unit,(unit))+ ") = " + l_x;
}
else {
l_x="d="+l_x;
}

it is a work of art and definitely a great java for sense making!

thanks!
http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=684.msg2452#msg2452
to see this great applet!
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #6 on: June 03, 2009, 08:57:04 pm » posted from:Taipei,T\'ai-pei,Taiwan

Good works! I believe you did feel great when you find out how to solve it by yourself.
 Logged
 Pages: [1]   Go Up
Everything has its beauty but not every one sees it. ...Confucius (551-479 BC)