Results 1 to 8 of 8

Thread: Kepler's laws demo

  1. #1

    Kepler's laws demo

    Here's an OpenGL demonstration of Kepler's three laws of planetary motion (source code only):

    http://www.ludicity.org/files/kepler.tar.gz (190 KB)

    The movement of the planet(s) is determined by numerically integrating Newton's equations of motion, rather than simply applying the analytical solution to those equations (which Newton worked out over three centuries ago, inventing calculus in the process!) But it's nice to see for oneself that numerical techniques can reproduce (to reasonable accuracy) the behaviour described by Kepler's laws.

    A few screenshots are here, here and here.

    You can switch from one law to the next/previous by using the RIGHT/LEFT arrow keys. SPACE pauses/resumes the simulation, and ENTER returns it to the starting state. L shows labels (and other info). You can click and drag the Sun and planet(s) around (when in the starting state) to change various orbital parameters. F1 for help on all these options and more.

    I've only tested it on Linux with the Free Pascal compiler. It uses the JEDI-SDL headers. Compilation is as simple as fpc -Mobjfpc kepler.pp
    [size=10px]"In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it's the exact opposite." -- Paul Dirac[/size]

  2. #2
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Kepler's laws demo

    Very nice work!

    I'll have to hold on to this one for future reference. One of my other projects may be able to incorporate something from it. (Space shooter)
    Jason McMillen
    Pascal Game Development
    Co-Founder





  3. #3

    Kepler's laws demo

    Awesome job! This one is a keeper for sure, and I'll be looking real close at Kepler's Law. I'm going to be hacking apart every line of code over the next few hours/days.

    I just thought of this, but FPC has never worked well on my PC (the compiler and not the compiled apps) so is there I chance I can get a compiled version from you?

  4. #4

    Kepler's laws demo

    Here's an executable compiled on WinXP:

    http://www.ludicity.org/files/kepler.zip (278 KB)

    I think there may be a bug with the 3rd law demonstration. The movement of the inner planet is a bit jerky. I'll look into it. I just wish I knew how to code in a more structured, less spaghetti-like manner.
    [size=10px]"In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it's the exact opposite." -- Paul Dirac[/size]

  5. #5

    Kepler's laws demo

    Thanks! Very, very interesting to see it for myself.

    Mind if I ask a few questions at this or other points? I might make use of this when I've the time to get back into game design.

    Just a heads up, but fullscreen and mouse input don't operate in the compiled version. I just remembered that I have access to a linux comp though.

  6. #6

    Kepler's laws demo

    But Keplers Law doesnt work if you attach a rocket to a planet and fly around randomly.

  7. #7

    Kepler's laws demo

    Quote Originally Posted by Robert Kosek
    Mind if I ask a few questions at this or other points? I might make use of this when I've the time to get back into game design.
    You can ask questions, but I can't guarantee an answer. I'm just an amateur at this sort of thing. I'll do my best, though.

    Just a heads up, but fullscreen and mouse input don't operate in the compiled version.
    Mouse input only works when the planets are paused and in their starting states. Press ENTER to get them into this state. You can drag the Sun in all three laws (this changes the eccentricity of the orbit), you can drag the two planets in the second law (this changes their starting position), and the inner planet in the third law (this changes its semi-major axis). I hope that works for you.

    The fullscreen problem is a Windows bug or limitation: SDL_WM_ToggleFullScreen doesn't work in Windows. But I know of a workaround for that problem, and so I'll add that in when I get the chance. For now, you can run the demo in fullscreen mode by using the appropriate command-line option. For example,

    kepler -f -g=1600x900

    will run the demo in fullscreen mode at a resolution of 1600x900. Run kepler -h to see some more command-line options.

    Quote Originally Posted by aidave
    But Keplers Law doesnt work if you attach a rocket to a planet and fly around randomly.
    Kepler's laws work for their intended domain of applicability: the gravitational two-body problem. For other problems in mechanics, one should apply Newton's laws, and take into account all the forces that are relevant to the situation. Like I did in my demo.
    [size=10px]"In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it's the exact opposite." -- Paul Dirac[/size]

  8. #8

    Kepler's laws demo

    Kepler's laws work for their intended domain of applicability: the gravitational two-body problem. For other problems in mechanics, one should apply Newton's laws, and take into account all the forces that are relevant to the situation. Like I did in my demo.
    fair enough

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •