Revolve an object around another object

mdtajghorimdtajghori Member Posts: 24
edited May 2012 in Working with GS (Mac)
Hey guys, as the title suggests, basically I have an object in the centre (sun for example) and I want another object to revolve around the first object. How do i accomplish this? Thanks!

Best Answer

  • simo103simo103 Posts: 1,331
    Accepted Answer
    check this out and many other helpful videos at www.gshelper.com:

Answers

  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    Can something like this be helpful?

    http://dl.dropbox.com/u/8244920/OrbitRotation.zip

  • mdtajghorimdtajghori Member Posts: 24
    Thanks a lot guys! Just wondering if I wanted the orbit to be elliptical, what changes do I make?
  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    In my demo open the red actor and on one of the first two rules add something to the attribute within the parenthesis. Play with numbers until you find what you're looking for.

  • aindovinaindovin Member Posts: 6
    The way I addressed this situation in JavaScript and HTML5 was the following:

    1) I decided I would traverse all the positions of a circle around a central point.

    2) You can represent the positions of a circle by radian values. So I created an array of 62 elements.
    0.0, 0.1, 0.2, etc. to 6.2

    Thus I have an array of a complete circle of radian values.

    3) Using Vector math and a fixed radius, I calculated the X Position and Y Position of the orbiting Actor/Sprite/Planet using the following math:

    Planet_XPOS = Sun_XPOS + (RADIUS * COS(RADIAN_VALUE))
    Planet_YPOS = Sun_YPOS + (RADIUS * SIN(RADIAN_VALUE))

    4) Note the RADIAN_VALUE is the array I initialized in step 2.
    So if you loop through the array from 0 to 62, the Planet will rotate clockwise.
    If you go from 62 to 0, it will rotate counter clockwise.

    I'm not sure if this helps.
Sign In or Register to comment.