Jeśli jesteś właścicielem tej strony, możesz wyłączyć reklamę poniżej zmieniając pakiet na PRO lub VIP w panelu naszego hostingu już od 4zł!
Strony WWWSerwery VPSDomenyHostingDarmowy Hosting
"I think nature imagination is so much greater than men’s. She’s never gonna let us relax." - R.P.Feyneman                 "Life is not amount of breaths you take it’s, the moments that take your breath away." - Hitch                 "Live as if you were to die tomorrow. Learn as if you were to live forever." - Mahatma Gandhi                 "I Love Living Life. I Am Happy." - Nick Vujicic                 "Why should I refuse a good dinner simply because I don't understand the digestive processes involved?" - Oliver Heaviside

Numerical Solving of Newton's gravity equations

Now day's everyone have a computer witch permit quite fast calculating. We using or rather losing its power to things like games. Why not use its to see how the lows of gravity move the planets on our computer screen? We often don't realize how important it can be in imagining how the nature works. It's worth to write a program by yourself which will be able to solving some of this gravitation equation (eg for two body). Here is my try:

I wrote my program in C++ with “allegro” graphic library which contains the basic 2D operations like putting a pixels, drawing lines and other staff which could be useful in program. It contains functions for getting data from keyboard and mouse too. Allegro is open-source project that means it’s for free and have a lot of tutorials.

The whole idea of this algorithm is that it doesn’t calculate position of bodies continuously but cut path S into little pieces: dS and check how will be x, y, Vx, Vy after moving by dS. What is more it must calculate how long took moving from earlier to later position. It can be done if we assume that speed of body during moving by dS doesn’t change, what’s of course can’t be true but for very little jumps and little accelerations it’s quite good approximation. This algorithm has drawback: accelerations of bodies can’t be too big (bigger acceleration, bigger precision, longer counting) I don’t want to give all source of this program because I hope that somebody will write other one and then we will compare results ;).

During writing this article I hit on an idea that good thing to do, is comparing change of total energy of system, it permit to conclude about accuracy of counting.

Here is movie that shows how it works:

Copyright © IronWolf 2010 - 2011