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

Easy Java Simulations (2001- ) => Questions related to EJS => Topic started by: lookang on July 12, 2010, 11:01:11 am



Title: how to make the mass m dragable n the world view in circular motion?
Post by: lookang on July 12, 2010, 11:01:11 am
Hi Prof Hwang and Ejs community,

how to make the mass m dragable n the world view in circular motion?

i seems to have encounter a problem which i need someone else to discuss with to understand why the mass cannot be drag.

in the fixed relation
x=R*Math.sin(cta);
y=R*Math.cos(cta); // jamming the on drag codes


in the object m
on drag i added these codes to execute when drag.
cta = Math.atan2(y,x);
R = Math.sqrt(x*x+y*y);
_initialize();

i don't see anything wrong with the method i used to make the mass m execute
cta = Math.atan2(y,x);
R = Math.sqrt(x*x+y*y);
but it does not work.

the remixed work is here http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1892.0


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: Fu-Kwun Hwang on July 12, 2010, 06:57:55 pm
What is the constraints when the mass was being dragged?
Is it has to be at fixed radius R or it can be at any radius?


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: lookang on July 13, 2010, 09:36:00 am
x=R*Math.sin(cta);
y=R*Math.cos(cta); // jamming the on drag codes
i made a yellow object which is on (x000, y000) seems to be able to drag.

i think the fixed relation
x=R*Math.sin(cta);
y=R*Math.cos(cta);
does not allow on drag.

let me look at it more closely ;D


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: lookang on July 13, 2010, 01:02:27 pm
i did it!

i assign another variable (x000,y000)
cta = -Math.atan2(y000,x000)+pi/2; // to make drag by angle
R = Math.sqrt(x000*x000+y000*y000); // to make radius vary as well
x= x000; // may not be needed
y= y000; // may not be needed
_initialize();

in fixed relation
x000=R*Math.sin(cta); // code for making object x000,y000 follow the equation of motion
y000=R*Math.cos(cta);


i reflect back in the method, i still don't see the codes that cause the jam in the first place, the difference is just x000,y000 assign another variables.
maybe the problem is
cta = Math.atan2(y,x);
R = Math.sqrt(x*x+y*y); in the old mass object (x,y).

while, it works now! enjoy! http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1892.msg6846#msg6846
thanks! this forum rocks! & i am working towards human kind’s well-being too  ;D




Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: Fu-Kwun Hwang on July 13, 2010, 07:51:37 pm
Normally, I will add
Code:
cta = Math.atan2(x,y);
R = Math.sqrt(x*x+y*y);
in the drag action.

And add
Code:
x=R*Math.cos(cta);
y=R*Math.sin(cta);
in the fixed relation section.

Please check out Circular motion in vertical plane (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=190.0)
(It has been updated so that the particle is drag-able)


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: lookang on July 13, 2010, 08:39:59 pm
it is very close to what i was doing conceptually, i follow your method as you have explained before about the codes inside on drag.
it could have been some additional codes i introduce.
not to worry! thanks!


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: ahmedelshfie on July 17, 2010, 10:58:52 pm
I try make the same that prof Hwang do in original applet that i drag by mouse
The mass to control in size of circular how ever i copy code from original applet with modified from me in initialization page
But work first time only and after i cant control in size of circular so i restor EJS and run again work applet and i drag circular
For control in size of circular.
Second test no work again can you prof Hwang check code that i do.


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: Fu-Kwun Hwang on July 18, 2010, 10:38:10 am
It is because you have 3 GUI elements all connect to (x,y) and there are all dragable.
1. Particle
2. mg
3. rod
So only the last one will receive mouse drag action.

The above order is the same order shown in the EJS GUI tree.
So the action for mouse move to (x,y) and drag was assigned to rod.

Because your action code is assigned to Particle
What you can do is
1. Change the above order so the Particle appear as the last GUI element
2. Change the dragable property for mg and rod to false

Remember: If there are several GUI elements assigned to the same variable, then the last one's action will be the one being executed.


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: lookang on July 19, 2010, 02:11:40 pm
I try make the same that prof Hwang do in original applet that i drag by mouse
The mass to control in size of circular how ever i copy code from original applet with modified from me in initialization page
But work first time only and after i cant control in size of circular so i restor EJS and run again work applet and i drag circular
For control in size of circular.
Second test no work again can you prof Hwang check code that i do.
maybe my code can help u figure out, the drag works on this
http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1892.msg6846#msg6846


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: Fu-Kwun Hwang on July 19, 2010, 05:14:55 pm
"Drag" is not working properly for the applet shown at the top (first message).


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: ahmedelshfie on July 19, 2010, 06:26:13 pm
Finish,, work very well i will attach jar file because no accept upload on Site.
I have ask source code of applets path is ejs not XML so i don't know
If this make applet no accept upload on site or me no understand this way of path to upload,, but im near sure problem is path ejs .
Could you prof Hwang explain to me please about path ejs and how i change to upload in site
Thanks
Here is a new version from circular motion!!


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: Fu-Kwun Hwang on July 19, 2010, 08:25:50 pm
It seems that you rename the ejs_circularvwee.jar to ejs_circularvwee25.jar.

I used the filename of the uploaded jar to find the ejs source (.xml or .ejs).
Because you rename ejs_circularvwee.jar to ejs_circularvwee.jar. so the server can not find the ejs source
and it stop the process.

Do not change the ejs generated jar filename. Upload as it is generated.
If you want another jar name, you should change the ejs source name.

I tried to change the code on the server so that it will accept .ejs as source.


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: ahmedelshfie on July 19, 2010, 08:37:59 pm
When i download modified version by lookang
I find he save path by ejs not by XML
But prof you mean if convert source code by path ejs and after upload on site server will understand this and accept upload or no?
And if no accept what i must do to me can upload jar file what i must change in source ?
I finish applet and i do all steps that you explain and work very well.
Thanks  :)


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: Fu-Kwun Hwang on July 19, 2010, 09:52:56 pm
EJS 4.3 support utf-32 characters and extension for the default source become "ejs" instead of "xml".

Before this evening: The upload jar file option at this server only support jar files generated with "xml" type source.
I have modified the code, so it is also support jar file generated with "ejs" type source now ( at least it works fine when I tested it).

You can try it again and it should work fine now.


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: ahmedelshfie on July 19, 2010, 11:15:32 pm
I see is work fine now i test applet work very well,, i notice no have download XML source code but this i think because
Now source code is another path so cant have XML source code.
A modified version on Circular motion in vertical plane (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1887.0)


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: Fu-Kwun Hwang on July 20, 2010, 12:46:21 am
I just modified the code to display link for ejs source with ".ejs" type.
However, I still need to modify code for view it online later.
It is really late now. I need to go to bed! May be work on it tomorrow!


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: ahmedelshfie on July 20, 2010, 12:49:12 am
Thanks for help prof,, I'm worked in applets that you design by JDK I'm improve my self in translations  :D Good night


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: ahmedelshfie on July 20, 2010, 08:59:54 am
I understand now part about path ejs but have another part im no understand is how i make
Applet source code ejs not XML for example im create or modified applet but i want path of source is ejs
How i do it.


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: Fu-Kwun Hwang on July 20, 2010, 05:58:09 pm
Before EJS version 4.2, the default file extension for ejs is "xml".
It has been changed to "ejs" since EJS 4.3
When you create a new ejs simulation and save it, you can just type the filename.
And EJS will save the file with extension ".ejs".

However, if you open previous simulation source where the extension is "xml".
Then, EJS will not change the extension so that previous version can be run as well.

If you really want to save the file with extension "ejs", then you can type the full filename (filename + extension".

May I know why you want the source to become "ejs" type? 


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: ahmedelshfie on July 20, 2010, 06:08:59 pm
Thanks prof,, i don't want source become ejs I'm ask for me understand every thing about ejs path i like more XML because if you remember
From time i begin learn EJS i work by XML but i meet some applets have path ejs so i think is more good i building database about this kind of path
Even i will not use,,but is good i have idea how it work.
By the way prof i worked in your applets by JDK is really wonderful and I'm sure for develop applets by JDK is very hard.
I have ask have applet i meet is RC Circuits (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=31.0) when i work in translation
I find some words inside applet like click red switch to start and other words like voltage,,current,,time have away to translation this words to portages.
Because i think this is inside class file for me change to portages i need to enter in file class right?
So have a way to me do it,, translation words inside applet or i cant do it ?
Thanks prof


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: Fu-Kwun Hwang on July 20, 2010, 10:44:10 pm
You will find a button "translate this message (and the strings in the simulation) into your local language.
Just click that button and you will find editable area for you to translate that posted message into your local language.
You will also find a table to translate strings used in the simulation.
Just edit that page and submit your result.
And you will received translated result in your email box after you post the translated data and click download button.
Please try it and you will find out it can be done easily.

"Click red switch to start" was not included in the translation. I will need to modify the code to add that one.
Do you really need it?


Title: Re: how to make the mass m dragable n the world view in circular motion?
Post by: ahmedelshfie on July 20, 2010, 11:08:10 pm
Im really test it before and work good with me i perfer translation by HTML is more good,,  about "Click red switch to start" i dont want busy you if have time
To modified okay if you no have time is no problem i will publish by this way.