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: ahmedelshfie on October 11, 2011, 06:19:18 pm



Title: How to add diffrent positions to trace in satellite motioin applet
Post by: ahmedelshfie on October 11, 2011, 06:19:18 pm
Hi prof,
i try to add slider for have diffrent positions to satellite so will be have also diffrent velocity, for example when satellite be near from earth velocity will be more fast and when be far
velocity will be more slowly, what i need to do that add slider for me control space between satellite and earth to can shown the diffrent velocity when change positions of satellite.
In case that i talk is this satellite motion at http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=2244.0 (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=2244.0)
Also i need to know how when i change position the satellite trace change automatic too.

thanks,


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: Fu-Kwun Hwang on October 11, 2011, 07:03:20 pm
You need to decide what will changed when the satellite position is changed.
(because this is not going to happened in real world, it can only happened in simulated virtual world).
For example: you can keep angular momentum is the same i.e. $L=r*m*v=m*r^2*\omega$ to be a constant.
or you can keep velocity to be  a constant.e. $v=r*\omega$ to be a constant, or even with any change in velocity.
The easiest way is to change property of satellite: let it become drag-able. You can pause the simulation, then drag the satellite to other position, and start the simulation again.
Or you can use slider to change it distant to the center of the simulation region.

The trace will follow automatically, since it x, y properties are assigned to x,y in the model.
Try it out first, I will try to help  if you can not do it by yourself.


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: ahmedelshfie on October 11, 2011, 08:00:58 pm
I change value of satellite image to draggable and add at variables page $v=R*w$ also i attach two image for what i add to you can watch.
but the part that is
Quote
For example: you can keep angular momentum is the same i.e. $L=r*m*v=m*r^2*\omega$ to be a constant.
I didn't know where i can add this value.
other thing after i change satellite image to draggable, when i drag the satellite to change postion happend like zoom to the applet, (but this not happend all times).

thanks,


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: lookang on October 11, 2011, 08:33:17 pm
Hi prof,
i try to add slider for have diffrent positions to satellite

thanks,

Hi ahmed
is this what u want?

so will be have also diffrent velocity, for example when satellite be near from earth velocity will be more fast and when be far
velocity will be more slowly, what i need to do that add slider for me control space between satellite and earth to can shown the diffrent velocity when change positions of satellite.
In case that i talk is this satellite motion at http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=2244.0 (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=2244.0)
Also i need to know how when i change position the satellite trace change automatic too.
prof hwang already has physics equation inside if u just want to change the initial position of y it is quite easy, check the jar file.


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: ahmedelshfie on October 11, 2011, 08:50:41 pm
first thx for help prof, but the jar file that you upload is diffrent what i need to do, for change postion of satellite, will also change velocity of satellite also trace as prof hwang say follow
satellite with any postion, in your modification if you notice when drag slider applet zooming too much, and velocity of satellite doesn't change even near or far earth.
i tried follow and understand steps that prof hwang explain.



Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: Fu-Kwun Hwang on October 11, 2011, 11:32:15 pm
You can drag the satellite and simulate different trajectory.
You can also check the show velocity  to change the velocity,too!

I just modify the satellite image (set draggable to true)!

This simulation can be used to illustrate kepler's 2nd law,too.
The # of trace points is the same (mean the same time interval), howevwr, the angle spread out is different.
It move much faster when it is closer to the earth, it move slower when it is far away from the earth.
However, the area is the same (from center of the earth, to both end of the trace)


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: ahmedelshfie on October 11, 2011, 11:44:53 pm
I do the same set satellite image draggable but also i add at variables page  $v=R*w$
So do you think is not necessary add V just set dragable to true.


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: Fu-Kwun Hwang on October 12, 2011, 07:49:08 am
It is useless if you just added variable in the model without using it as a constraint.
You will find it make no difference in the simulation if you remove it.


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: ahmedelshfie on October 13, 2011, 05:21:35 pm
I understand, now prof i test the applet to watch the movement with diffrent positions, however is work fine but I'm now test the calculate the applet when change postion, some cases
The satellite move too fast when i keep he in the center of earth.
Thanks,


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: ahmedelshfie on October 14, 2011, 07:38:47 pm
hi prof, i have question: how when i drag satellite from postion to another make trace no drag together satellite and just work after i finish drag satellite to the new postion,
i want when change satellite postion trace stop still i keep satellite at the new postion that i choose trace back work without connect with the last trace postion.
I'm attached image for the applet and mark the error with red colour.
thanks, 


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: ahmedelshfie on October 17, 2011, 04:16:23 pm
prof hwang, i tried many ways to find how i can drag the satellite with tarce follow he, as the image that i attach in my last post, i tried to know how i can do it.
Please any ideas will be helpful to me.
thanks


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: Fu-Kwun Hwang on October 17, 2011, 07:49:58 pm
There are two properties which control tracedrawing:
1. Active: when it is true , a new point will be added to trace for each time step
2. Connected: when it is true, a segment will be draw to connect between last point and new added point.

You need to set Connect to false when drag.


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: ahmedelshfie on October 18, 2011, 04:18:36 pm
Thanks for the valuable information, is work fine now, i was search in wrong side.


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: ahmedelshfie on October 18, 2011, 07:49:20 pm
Hi porf, i have other question, for example if i want to control by value to change postion of the satellite not by drag using mouse, however
for example at applet $y=R*2$ so i change the value to $y=R*1.5$ the satellite become near from the earth.
How i can add three diffrent postions to satellite for i can change value using value input not using drag satellite image, for example i put 1.5 and click enter so satellite postion change to
this postion also if i change the value fro 1.5 to for example 2 etc..
thanks,


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: Fu-Kwun Hwang on October 18, 2011, 10:47:56 pm
The main parameters for the above simulation are x and y.
and $r=\sqrt{x^2+y^2}$, $\tan\theta=\frac{y}{-x}$ (cta is the variable for $\theta$)

You can find the above relations from constraints page in EJS.
Code:
cta=-Math.atan2(x,y);
 r=Math.sqrt(x*x+y*y);

If you want to add slider or numerical input for r (to change r by slider or numerical input).
you need to add code (at On drag property: i.e what need to be changed when the slider were dragged).

You can add the following code for the Drag Action for the slider

Code:
cta=-Math.atan2(x,y);
 x=-Math.sin(cta);
 y=Math.cos(cta);

However, you need to change
Code:
double r,r2,r3,cst;
in Custom page to
Code:
double r2,r3,cst;

and add a new variable r in the variable page (so that you can use it in view too).


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: ahmedelshfie on October 18, 2011, 11:33:33 pm
Thanks prof, i follow all the steps the you explain in your last post, and slider work but it's normal that space between trace and other not be equal, i tried to make the space between
each trace and the other be equal for applet be more simple, for example if we have 3 diffrent tracks what i tried to do is be space between the three trace be equal slider move satellite normal, but when i move satellite to other postion using slider the space of the trace old and the new Trace that follow satellite not be equal, be diffrent, i really need to when change satellite to diffrent postion space be equal between all traces.
i really need help  in this point too, i also attach the XML file to you can watch what i add.
PS: I'm not sure the slider if work completely right or no.
Thanks,


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: Fu-Kwun Hwang on October 19, 2011, 07:44:56 am
1.  The satellite should be at location larger than the radius of the earth, so the range for r should not be from 0 to 1.
You need to change the minimumk value.
2. The velocity is kept the same , and the radius is changed. The gravitation force is different for different r.
So the trace will not be similar. It is the physics which decide the trajectory.

Please check out kepler motion (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=9.0) and select fixed Kinetic energy from the menu (the same as your case.)

And you should find different trajectories for different r (You can drag velocity vector in the simulation to change r).

You will also need to change velocity if you want similar shape trajectory.


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: ahmedelshfie on October 19, 2011, 04:58:17 pm
thanks too much porf for help, but i still have some questions:-
1. when i drag slider to change satellite is running too fast, what the value you suggest for me set at the minmum and mixmum value?

2.this part
Quote
You will also need to change velocity if you want similar shape trajectory.
did you mean velocity in this case is r and how i change velocity at the applet for me have similar trajectory?

3. when drag slider trajectory change as he follow the satellite, but how i can add 3 diffrent levels at slider that give three different trajectory at applet with equal space for example slider v begin by value 0.5 and center by value 1 and finish by value 1.5 each value change trajectory and in this case will have 3 diffrent trajectory with equal space.

thanks too for help.





Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: Fu-Kwun Hwang on October 19, 2011, 05:45:40 pm
The only thing I can say is:
The minimum value should be larger than the radius of the earth.
The maximum depend on how fast ($\vec{v}$ and direction)and where you set it.

It is a easy problem only if it is a circular motion.
Gravitation force provide the necessary force $\frac{GMm}{r^2}=m\frac{v^2}{r}$
So  you can set $v=\sqrt{\frac{GM}{r}}$

It would become a very difficult problem if it is not circular motion.
Draw the effective potential might help(like the potential in the kepler motion  (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=9.0)page.

Remember: It is the physics law combine with initial values which decide the trajectory.


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: ahmedelshfie on October 19, 2011, 07:36:22 pm
well, i set $v=\sqrt{\frac{GM}{r}}$, but how i can know the radius of the earth for i can decide the minmum value at slider?
the other part i understand.

thanks



Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: Fu-Kwun Hwang on October 20, 2011, 02:51:12 pm
It is not the real radius for our earth. It is the radius of the image for the earth used in the simulation.
The size x,y for the earth is twice the radius of the earth in your simulation.
You should be able to find it from property for earth's image used in EJS.


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: ahmedelshfie on October 20, 2011, 10:20:08 pm
Dear porf hwang, thanks too much for help and support, your guide was helpful to me, i have just comment about trace, after you explain to me about the i set connected
to false i drag satellite first time work fine and trace not follow he, but when i drag for second time or more appear again that trace follow satellite to the next point i drag, how i can solve this for be can drag many times without happend it.

thanks,


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: Fu-Kwun Hwang on October 21, 2011, 08:23:47 pm
Just set connected to false would not do the job.

You do not want the trace(connected and active to false) when it is being dragged, and you want connected to be true when it is playing.

You can do the following to solve the problem:

1. add the following to drag action for the satellite
Code:
t=0;

2. set connected to t>dt , and set active to t>0


Title: Re: How to add diffrent positions to trace in satellite motioin applet
Post by: ahmedelshfie on October 21, 2011, 10:34:25 pm
Dear porf hwnag, thanks too much, you the hero, he is work fine and hte probelm be solved.
Thanks again  :D