NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
October 22, 2017, 04:31:10 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Discovery consists of seeing what everybody has seen and thinking what nobody has thought. ..."Albert von Szent-Gyorgyi(1893-1986, 1937 Nobel Prize for Medicine, Lived to 93)"
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1]   Go Down
  Print  
Author Topic: Demo for BField (create two coils and find out the field lines  (Read 27794 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
on: August 30, 2007, 11:08:32 am »

This demo shows how to create coils and display magnetic field line when double clicked into the simulation region.

Click Physlet Builder to try it online.


Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #1 on: August 30, 2007, 09:14:55 pm » posted from:Singapore,,Singapore

movie not loaded  Grin
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #2 on: August 30, 2007, 09:33:01 pm »

Sorry! It should work now.
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #3 on: September 02, 2008, 10:24:07 am » posted from:Singapore,,Singapore

i was exploring making a bar magnet using the builder

i made 2 coils align side by side and i could not figure out how to make the drag function

when the coils is drag, both coils move

can it be done on Physlets® html codes ?

http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=741.msg2753#msg2753

 name="AppletNames" value="Bfield">





Physlets®, i.e., the Java applets themselves, are a registered trademark of Wolfgang Christian.
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #4 on: September 02, 2008, 02:34:47 pm » posted from:Taipei,T'ai-pei,Taiwan

You have added:
fkh.setDragable(id1,true);fkh.setDragable(id3,true);

So two of the coils can be dragged.


Quote
when the coils is drag, both coils move
Huh

Only the one being dragged is moving with the mouse.
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #5 on: September 03, 2008, 09:45:52 am » posted from:SINGAPORE,SINGAPORE,SINGAPORE

is there a way to set a constraint to force the drag to move id1 to id20 which are my magnetic coils, to move as one object?

in EJS, i think is possible Smiley in Physlet i hope can ?
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #6 on: September 03, 2008, 05:26:13 pm » posted from:Taipei,T'ai-pei,Taiwan

You can do almost what you want if you find the right functions available in physlet library and javascript codes.
Check out http://webphysics.davidson.edu/Applets/PhysletsDoc/index.html for information about physlet available functions.

You have the following javascript physlet code:
id1=fkh.addObject("coil","x=0,y=0,i=1,r=0.1");id2=fkh.addObject("coil","x=0.02,y=0,i=1,r=0.1");id3=fkh.addObject("coil","x=0.04,y=0,i=1,r=0.1");id4=fkh.addObject("coil","x=0.06,y=0,i=1,r=0.1");id5=fkh.addObject("coil","x=0.08,y=0,i=1,r=0.1");id6=fkh.addObject("coil","x=0.1,y=0,i=1,r=0.1");id7=fkh.addObject("coil","x=0.12,y=0,i=1,r=0.1");id8=fkh.addObject("coil","x=0.14,y=0,i=1,r=0.1");id9=fkh.addObject("coil","x=0.16,y=0,i=1,r=0.1");id10=fkh.addObject("coil","x=0.2,y=0,i=1,r=0.1");id11=fkh.addObject("coil","x=0.18,y=0,i=1,r=0.1");id12=fkh.addObject("coil","x=0.22,y=0,i=1,r=0.1");id13=fkh.addObject("coil","x=0.24,y=0,i=1,r=0.1");id14=fkh.addObject("coil","x=0.24,y=0,i=1,r=0.1");id15=fkh.addObject("coil","x=0.26,y=0,i=1,r=0.1");id16=fkh.addObject("coil","x=0.28,y=0,i=1,r=0.1");id17=fkh.addObject("coil","x=0.28,y=0,i=1,r=0.1");id18=fkh.addObject("coil","x=0.3,y=0,i=1,r=0.1");

where id1,id2,...id18 are integer variables. from the above web page you can find
double   getX(int id):  Get the x position of an object.
 boolean   setX(int id, double x)  Change the x of an object.
So if you only set id1 dragable with code
fkh.setDragable(id1,true);

Then, you can use x1=getX(id1); to get x coordinate for the dragged coil
then you can add
setX(id2,x1+=dx);
setX(id3,x1+=dx);
....
to set all the coils.
If you want user to drag coil in horizontal only. add the following code
setY(id1,0); // to fix y coordinate for the first coil


It will be easier if you use array object
for examples:
id=new Array(18);
x1=0;
for(i=0;i<18;i++){ // use this loop to create coils
 id=fkh.addObject("coil","x="+x1+",y=0,i=1,r=0.1");
 x1+=0.2;
}
Then it will be easier to move all the coil together
x1=getX(id[0]); y1=getY(id[0]);
for(i=1;i<18;i++){// move all the coils (x,y) together
 setX(id,x1+=dx);
 setY(id,y1);
}
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #7 on: September 08, 2008, 01:33:49 pm » posted from:Singapore,,Singapore

amazing stuff, a bit difficult to follow for click click click type of users.

i found  http://webphysics.davidson.edu/Applets/PhysletsDoc/bfield/BField.html

setX

"public boolean setX(int id,
  double x)

  Set X position of an object.

  Parameters:
  id - The ID of the object.
  x - The x coordinate."

i don't see

getX(int id):  Get the x position of an object. i can find getBx and getBy.


 but how do i use the code
"
x1=getX(id[0]); y1=getY(id[0]);
for(i=1;i<18;i++){// move all the coils (x,y) together
 setX(id,x1+=dx);
 setY(id,y1);
}
"
inside the rest of the html codes?

is there any examples to follow the syntax ? Grin


 




Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #8 on: September 08, 2008, 04:02:40 pm » posted from:Taipei,T'ai-pei,Taiwan



 name="AppletNames" value="Bfield">




OOPs! You are correct. There is no getX function available.
I will write to Prof. Wolfgang and ask him what can be done to have the same effect.
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #9 on: September 09, 2008, 01:07:16 pm » posted from:Taipei,T'ai-pei,Taiwan

Prof. Wolfgang told me that : setX,setY and getX, getY will conflict with default java method.
So the function name have been change to setXPos, setYPos and getXPos,getYPos.

You can drag the leftmost coil in the previous physlet, then you need to click the button to move coils to new dragged position.

However, There is no onClick event available in physlet library.
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #10 on: September 09, 2008, 02:00:20 pm » posted from:Singapore,,Singapore

1. the applets did not load on this page, is it because there are 2 applets ( one above by me, one just above by prof. hwang). strange maybe i am using firefox and i also open http://webphysics.davidson.edu/Applets/Poisson/Faraday.html

i think restart computer will solve it Smiley

it is super cool!!!, i saw it, it is fantastic!!


2. i can't modify your post to "see", how you use the coding, chance to discuss over at the board where i am a moderator ?
http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=741.msg2753#msg2753


thanks!
« Last Edit: September 09, 2008, 02:13:21 pm by lookang » Logged
basementfloor
Newbie
*
Offline Offline

Posts: 1

«
Embed this message
Reply #11 on: May 09, 2012, 01:23:06 pm » posted from:New Delhi,Delhi,India

thanks...for...sharing....


-*-
Logged
roasting-88
watchlist
Newbie
*
Offline Offline

Posts: 1

«
Embed this message
Reply #12 on: September 18, 2012, 12:15:21 pm » posted from:Bangkok,Krung Thep,Thailand

มันๆๆ  Shocked Shocked Shocked
Logged
Comics-55
Newbie
*
Offline Offline

Posts: 2

«
Embed this message
Reply #13 on: September 19, 2012, 03:27:45 pm » posted from:Bangkok,Krung Thep,Thailand

ลุ้นด้วยกันป่าว Roll Eyes Roll Eyes Roll Eyes Roll Eyes
Logged
Pages: [1]   Go Up
  Print  
Discovery consists of seeing what everybody has seen and thinking what nobody has thought. ..."Albert von Szent-Gyorgyi(1893-1986, 1937 Nobel Prize for Medicine, Lived to 93)"
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Demo for animator (create particle moving along an analytic curve and plot graph
Physlet builder (Create your own simulation)
Fu-Kwun Hwang 4 15288 Last post January 30, 2010, 04:50:56 am
by weareza009
Demo for EField (two point changes, drag one of them and see force/field lines)
Physlet builder (Create your own simulation)
Fu-Kwun Hwang 23 31596 Last post February 17, 2016, 04:10:07 pm
by rahulverma007
Ejs Open Source 2 Charge Model with Field Vector, Field Lines, Potential Visual
Collaborative Community of EJS
lookang 12 14596 Last post August 15, 2013, 07:41:28 am
by lookang
Ejs Open Source 2 Mass Model with Gravity Field Vector, Field Lines, Potential
Collaborative Community of EJS
lookang 1 6268 Last post September 06, 2011, 06:40:27 pm
by lookang
Ejs Open Source Magnetic Dipole Field Vector & Field Lines 3D Model Java Applet
Collaborative Community of EJS
lookang 2 7204 Last post December 13, 2012, 10:03:40 am
by lookang
Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.084 seconds with 23 queries.since 2011/06/15