NTNUJAVA Virtual Physics LaboratoryEnjoy the fun of physics with simulations! Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
September 21, 2018, 05:45:58 pm

Teaching without words. ...Lao Tzu (570-490 BC)

 Pages: [1]   Go Down
 Author Topic: help in programming  (Read 15006 times) 0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
kahhean
Newbie

Offline

Posts: 2

 « Embed this message on: April 01, 2006, 04:11:48 pm »

Hi,

I have been experimenting with EJS and it has been quite exciting. However, when I run into problems I do not have any one in the office to turn to. :-(

My two big problems are :

1) I wrote a program where I could set the initial trajectory of a body which is subject to gravitational pull towards a fixed point in the centre. So I hope to simulate the different outcomes when the initial velocity is changed (like the newton's cannon). So I set up the acceleration, and use the ODE to work out the velocity and position vector for me. (dvx/dt=ax and dx/dt=vx and so on). However, the outcome has a little error which accumulates after every round. If I changed the time step to a very small number I can eliminate this error but the simulation becomes painfully slow. I tried changing the method used for solving the ODE and none worked. Can anyone tell me how to solve this problem?

2) One thing I commonly want to do is to have two objects in one drawing canvas. Each object has all sorts of arrows associated with it. I find it a chore when making another copy of the same object. I have to copy and paste every arrow. Is there any better way?

Regards
kahhean
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3080

 « Embed this message Reply #1 on: April 03, 2006, 02:50:02 pm »

You can always post your question here (this forum).

Please send email to hwang@phy,ntnu.edu.tw and attach you ejs source.

The best ODE solver is Runge-Kutta 4th orrder methos. There are several similar example under Simulations subdirectory. Please check out those examples.

If you have several arrow, please use arrowSet instead of arrow for each object.

Fu-Kwun
 Logged
 Pages: [1]   Go Up
Teaching without words. ...Lao Tzu (570-490 BC)