Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Programming challenge, gravity
Message
De
23/06/2004 22:35:36
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
23/06/2004 15:52:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00916106
Message ID:
00916706
Vues:
24
>I'm not sure this applies to the example I've written. It basically works like this:
>
>
do while .t.
>   Gravity()
>   Inertia()
>enddo
>
>Every object has a position and a speed, the Gravity function changes the speed of the object based on sourrounding objects and Newton's law. The inertia just pushes every object in the direction its headed at its speed.
>
>I suppose you could do your calculuation of gravity every N times, like so:
>
>
do while .t.
>   Gravity()
>   for x = 1 to N
>      Inertia()
>   endfor
>enddo
No, I think it is more like this: If I understand correctly, Gravity() will change the velocity of the object; Inertia() will calculate the difference in the object's position.

Both can be applied once every second (in physical time; not in animation time, which will most likely be scaled), or once every hour, or once every day, for instance.

Both should be calculated together, IMO; calculate Gravity() once, and Intertia() once.

Now, let's assume your program currently does the calculations every second, and you want to change this to do the calculations once every hour.

In one hour, the gravitational acceleration (assuming constant acceleration) is 3600 times as much as in one second, so you will have to multiply the difference in velocity by 3600 - as compared to a single second.

Also in one hour, assuming a constant velocity, the object will move 3600 times as far as in one second, so you have to multiply the distances moved by that factor.

The assumptions of constant acceleration and constant velocity get less and less accurate, as you choose ever longer time intervals. The speed of calculation improves, but its accuracy decreases.

I think the method you are using is known in astronomy as "numerical integration".

"Integration" means adding a lot of small parts together (the pieces of the orbit), to get a result.

"Numerical" means that the parts are actually added, without using shortcuts (a shortcut might be the known fact that a planet has an eliptical orbit around the sun; from that starting point, find deviations due to the attraction of additional bodies).
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform