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 June 25, 2005, 10:45:35 am



Title: Summation of vectors
Post by: Fu-Kwun Hwang on June 25, 2005, 10:45:35 am
This applet shows how to add several vectors together.
You can change the number of vecotrs with slider bar.



You are welcomed to check out related applet: How to do summation of three vectors (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=2018)


Title: summation of vectors
Post by: sreejat on January 05, 2006, 09:15:35 pm
Plz send me the xml file of this to:
sreejat@it.iitb.ac.in


Title: topic216
Post by: Fu-Kwun Hwang on January 06, 2006, 09:47:08 am
You should have received xml file in your email account.


Title: Re: Summation of vectors
Post by: lookang on May 02, 2008, 11:02:12 am
working on a similar applet

for learning:

Add two vectors to determine a resultant by a graphical method
taken from http://www.seab.gov.sg/SEAB/oLevel/syllabus/2009_GCE_O_Level_Syllabuses/5058_2009.pdf

work in progress.....


and then for
add and subtract coplanar vectors.
taken from http://www.seab.gov.sg/SEAB/aLevel/syllabus/2008_GCE_A_Level_Syllabuses/8866_2008.pdf



Title: Re: Summation of vectors
Post by: lookang on May 07, 2008, 08:42:22 am
another work in progress, but i think u will like it.

enjoy ;D


Title: Re: Summation of vectors
Post by: lookang on May 07, 2008, 11:02:07 am
question:

how did u make the resultant to be drawn using the array?


i can't figure out the variable assigned to the resultant?

i tried PX[2] and PY[2] thinking that is how u loop the adding but the display shows zero.



Title: Re: Summation of vectors
Post by: Fu-Kwun Hwang on May 07, 2008, 12:14:16 pm
for example:

define n=30; R=100.; and declear xp[n],yp[n] at Variable Panel
Then I can add the following code at Initialize Panel to draw a circle.
Code:
double dc=Math.PI/n,c;
for(int i=0;i<n;i++){
 c=i*dc;
 xp[i]=R*Math.cos(c);
 yp[i]=R*Math.sin(c);
}
Assign xp,yp as x,y property for polygon, and set the number of point to n


Title: Re: Summation of vectors
Post by: lookang on May 07, 2008, 03:42:34 pm
ok, thanks for the reply.....

i solved the problem by reassigning my own variables.


i am thinking of making a 4 check boxes,

which only one can be choosen at any time.

0. none
1. style 1
2. style 2
3. style 3

http://www.colorado.edu/physics/phet/simulations/vectormath/vectorMath.swf
any simple solution like a drag and drop menu or checkbox?

or do i need to write a object code for it? any sample link on the forum ?

thanks!!


Title: Re: Summation of vectors
Post by: Fu-Kwun Hwang on May 07, 2008, 10:58:59 pm
1. You can select multiple checkboxs (square one), But you only select one from radio buttons. (circle one)
2. Why you need a menu or check box to be able to drag and drop? Do you really mean that you want to be able to drag and drop those vectors. You just create ArrorSet in the view and it can be dragged one at a time.

 You can also create ArrowSet which is invisible. And when you click on it, make one of the arrow move with the mouse position (You can get mouse coordinate x,y from property of DrawingPanel). Then you have a drag and drop effect.

I believe I can give you better suggestion if you write download in detail what you really want to do.



Title: Re: Summation of vectors
Post by: lookang on May 12, 2008, 10:58:46 am
look at my xml


the buttons seems to be working the way i want, when checked show the components


but i followed the logic in http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=544.0

by using the
Action On
showComponent2=showComponent3=None=false;

but it doesnt work like yours on http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=544.0

chance to look at my code


Title: Re: Summation of vectors
Post by: Fu-Kwun Hwang on May 12, 2008, 10:49:52 pm
I did check out your file. But I am really confused because you have variable named the same as function name (e.g.  showComponent).

I do not know what the purpose for those functions. Please explain in detail what you want to do and the way you try to implement. 


Title: Re: Summation of vectors
Post by: lookang on May 13, 2008, 07:52:49 am
these pictures may help, that is what i want, only one state at any time.
the buttons on the right bottom is my attempt to make the one state show component.

my current applet has 4 buttons which allows learner to toggle between the 4 states of components but to turn off, need to recheck the checkboxes. (NOT what i want)

0. None
1. show component 1
2. show component 2
3. show component 3


Title: Re: Summation of vectors
Post by: lookang on May 19, 2008, 09:47:47 pm
i think u want this to debug?
thanks!


Title: Re: Summation of vectors
Post by: lookang on May 20, 2008, 12:21:48 am
http://www.ted.com/talks/view/id/216

this video is talking about new ways of collaboration , like me n you !


html code not enabled?




Title: Re: Summation of vectors
Post by: Fu-Kwun Hwang on May 20, 2008, 09:37:31 pm
It is really a nice talk. I like the ideas and we should all start to share our knowledge and collaborate with each other to make a better world for us and for our children. If you can read Chinese, you are welcomed to visit my Chinese physics forum at http://www.phy.ntnu.edu.tw/demolab/phpBB/ . You will also find more educational resources. If you are interested in content management system, visit http://enjoy.phy.ntnu.edu.tw/  (I was modified from moodle + blog + wiki + ... many free tools developed by people around the world.)


Title: Re: Summation of vectors
Post by: lookang on May 20, 2008, 10:10:45 pm
yes i will visit....btw can look at my codes on the component thingy? thanks!


Title: Re: Summation of vectors
Post by: Fu-Kwun Hwang on May 20, 2008, 11:14:12 pm
There is some error when I open your xml. However, I create another example for you.
I think the effect shown in the following applet is what you want. You can download the xml file and find out what I did. You can also drag the vector.


Title: Re: Summation of vectors
Post by: lookang on May 20, 2008, 11:29:39 pm
close enough!!!

i will look at the codes soon :)


Title: Re: Summation of vectors
Post by: lookang on May 21, 2008, 12:04:43 am
i figured out the logic, by trial n error :)


VIEW2[1]=false;
VIEW2[2]=false;
VIEW3[1]=false;
VIEW3[2]=false;
VIEW4[1]=false;
VIEW4[2]=false; for None

or for(int j=1;j<n;j++)
   VIEW2[j]=false;
   VIEW3[j]=false;
   VIEW4[j]=false;

the variables controlling them is VIEW2,VIEW3,VIEW4 and NOT showComponent2,showComponent3,showComponent4.




Title: Re: Summation of vectors
Post by: lookang on May 21, 2008, 12:49:37 am
what does this code do?

Code:
public void showComponent () {
  for(int i=1;i<n;i++)
  VIEW2[i]=showComponent;
}


i was changing it to VIEW3[i]=showComponent; or VIEW4[i]=showComponent;


but the applet appears to behave the same way



i managed to get the None, and First component to work fine even for 2 vectors A and B


But when only one vector A, everything works the way i can understand

but when vector A and B, the 3rd and 4th button shows the resultant ??

i not good with array, can explain ? ;D


Title: Re: Summation of vectors
Post by: Fu-Kwun Hwang on May 21, 2008, 04:51:45 pm
The following code does not make sense

public void showComponent () {
  for(int i=1;i<n;i++)
  VIEW2=showComponent;
}

It is the same as

public void showComponent () {
  VIEW2=showComponent;
}

Because you are asking java to do the same instruction: VIEW2=showComponent; n-1 times.


for loop is used for doing repeated jobs. Normally works better with array.
i=1; // is for initialization (Normally, i will be set to 0, because array starts from 0, for example: if you define x[n], then you will have n variables: x[0], x[1],...[x[n-1])
 
Then it will do whatever inside the for loop,
 when it is done, it will execute i++ (i++; is the same as i=i+1;).
So , i become 2, and it will do whatever inside the for loop again,
...  repeate if i<n is satisfied.


Title: Re: Summation of vectors
Post by: lookang on May 21, 2008, 10:37:20 pm
i think this forum setting recognize the square bracket as codes like html and /html

but strange in earlier posts no problem displaying
Code:
[i]

italics !!!!! i see

i had the array i in square bracket when i copy and paste but the forum disable them...

no wonder it does not mean sense :(


Title: Re: Summation of vectors
Post by: lookang on May 21, 2008, 10:40:02 pm

i think firefox got problem with java in new versions, recently java keeps hanging/crashing firefox


Title: Re: Summation of vectors
Post by: Fu-Kwun Hwang on May 22, 2008, 05:18:42 pm
The php script for this forum was updated to latest version a few days ago.
But I think you still can use command between square bracket. For example:
Quote
i think firefox got problem with java in new versions, recently java keeps hanging/crashing firefox
I have no problem viewing java with my firefox browser. :-)