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: snikalay on April 23, 2009, 09:07:01 pm



Title: Some questions about JVS
Post by: snikalay on April 23, 2009, 09:07:01 pm
Hi,

I am a student and I want to use the JVS for a project. I have some knowledge about Java and programming in general. Can you help me with the following questions:

Is it possible to create classes of objects that are in a simulations for example:
- class robot: that has the possibility to move and to accelerate and break with the restriction that has a collision avoidance function that can not allow to have a collision between 2 or more such objects. The path is known for each robot and is not random
- class box: a robot carry a box from A to B. The box doesn't have any dynamics only the coordinates.
Is it possible to create a more flexible environment for a simulation like giving for the user to chose how many objects and how to arrange the objects on this 2D board?
Do you have a model or example of such a problem from where I could start?

Thank you in advance,
Niko.





Title: Re: Some questions about JVS
Post by: Fu-Kwun Hwang on April 23, 2009, 11:00:19 pm
I do not know the meaning of "JVS" ?
It is possible to create class to do what you want.
The question is you need to structure your design into model and rules.
You might want to learn to program it with EJS.
You are also welcomed to check out all the simulations at this web site.


Title: Re: Some questions about JVS
Post by: snikalay on April 24, 2009, 06:54:30 pm
Hi again,

"I do not know the meaning of "JVS" ? "

My mistake I was in a hurry, I wanted to write EJS -Easy Java Simulations.

"The question is you need to structure your design into model and rules.
You might want to learn to program it with EJS."

What I wanted to say with that class is that I want to create a mathematical model but with the features from object oriented programming. As I said I want to be able to define many objects Robot that have the same features (same equations for movement, same methods) but each to behave as stand alone entity and to perform a stand alone task. To go further let's take for example that simulation made by you called "traffic control simulation". For example if I want to introduce in that model the a random turns for each car that is coming to a intersection and I want to create the class car that holds the information and methods for each car is it possible to do that in EJS? Can you give me an example of yours where you used this kind of approach - classes?
I want to use this kind of structuring for future development.

Can you help me to find a good explanations(documents, links or may be you already explained somewhere) about how EJS is working?

Regards,
Niko.



Title: Re: Some questions about JVS
Post by: Fu-Kwun Hwang on April 24, 2009, 08:39:21 pm
EJS is a java code generator. It is not designed for professional programmer. It is designed for user who know about the physics model but lack of programming skill and detail java programming. But the user need to understand basic program structure and logic. It has build in GUI interface so that user can use it directly. User just need to assign properties to variables/values defined in EJS. EJS also has build it numerical solver to do numerical integration for you.
Please check out Information and Download (http://www.phy.ntnu.edu.tw/ntnujava/index.php?board=11.0) for related information and documents. There are pdf files and html pages about EJS, please read it first.
You would not be able to define class in EJS. But you can write your own java class and import into EJS.
I used to write java code line by line (befroe 2001). But I switched to EJS when I learn about EJS.
It save me a lot of time. Most of the simulations can be created within several hours because I do not need to write code to create GUI elements.
I did not define java class in "traffic control simulation". I add all the necessary code in EJS.
You can add code in "Fixed relaton pages" if you just want to add random turn when car arrive at an interaction.
For example:
Code:
if x[],y[] and vx[] and vy[] are position and velocity vector for each car.
for(int i=0;i<n;i++){
 if(car_at_interaction(i,x,y)){// define function car_at_interaction to check ith car arrive at interaction
   if(vx[i]==0){// car moving in y direction
     if(Math.random()>0.5){
      vy[i]=vx[i];// car make a left turn
     }else{
      vy[i]=-vx[i];// car make a right turn
     }
     vx[i]=0;
   }else {// car moving in x direction
     if(Math.random()>0.5){
      vx[i]=vy[i];// car make a left turn
     }else{
      vx[i]=-vy[i];// car make a right turn
     }
     vy[i]=0;
   }
 }
}


Title: Re: Some questions about JVS
Post by: ChaWhoZer on July 04, 2009, 01:39:01 pm
I do not apperceive the acceptation of "JVS" ?

It is accessible to actualize chic to do what you want.

The catechism is you charge to anatomy your architecture into archetypal and rules.

You ability wish to apprentice to affairs it with EJS.

You are aswell accustomed to analysis out all the simulations at this web site.


-*-



Title: Re: Some questions about JVS
Post by: aufche on November 05, 2009, 08:30:58 am
very confused for me....i learn PHP...its help to understand this topics?-*-