Notices
Results 1 to 9 of 9

Thread: Help on Orbiting objects

  1. #1 Help on Orbiting objects 
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    Hello everybody, I need to design a swarm system with n-bodies and I have an issue:

    when 2 objects get close to each other (distance less than r_max) they start interacting and enter a formation. The formation I want is one in which one object moves and the other orbits around it. The orbiting object has to always stay within the r_max distance from the other object and cannot move faster than d_max per time_step.
    I cannot use the global position of the objects for the calculations, but I know the distance between the 2 objects and the relative angle between the 2.
    So far I have this formula:

    f(x,y) = e^(-alpha*dist^2)
    dx = alpha*f(x,y)*sin(theta)*dist;
    dy = -alpha*f(x,y)*cos(theta)*dist;

    I return those dx and dy which are going to be added to the global position outside of this function.
    If I use this formula, however, the f(x,y) becomes smaller and smaller or larger and larger depending on alpha so the object doesn't stay in orbit.
    Can anyone help me getting the object to move at a maximum speed of d_max per time_step and staying in an orbit with a distance that never exceeds r_max?
    For semplicity we can assume that the object that doesn't orbit moves at a speed way lower than d_max per time_step
    Thank you very much in advance
    Reply With Quote  
     

  2. #2  
    Senior Member
    Join Date
    Jan 2014
    Posts
    185
    Quote Originally Posted by 8mike View Post
    Hello everybody, I need to design a swarm system with n-bodies and I have an issue:

    when 2 objects get close to each other (distance less than r_max) they start interacting and enter a formation. The formation I want is one in which one object moves and the other orbits around it.
    Is this a real word problem or for a game program?

    If it is real-world, what you describe violates a few conservation laws unless you have a collision. That a planet captures a moon is a story often told to the general publik. Their view obtained is, invariably, science fiction.
    Reply With Quote  
     

  3. #3  
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    Quote Originally Posted by Useful Idiot View Post
    Is this a real word problem or for a game program?

    If it is real-world, what you describe violates a few conservation laws unless you have a collision. That a planet captures a moon is a story often told to the general publik. Their view obtained is, invariably, science fiction.
    It is a quadcopter swarm simulation
    Reply With Quote  
     

  4. #4  
    Senior Member
    Join Date
    Jan 2014
    Posts
    185
    Quote Originally Posted by 8mike View Post
    It is a quadcopter swarm simulation
    I see. Somehow I'd missed that.
    Reply With Quote  
     

  5. #5  
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    So is there a way to make it work?
    Reply With Quote  
     

  6. #6  
    Member
    Join Date
    May 2013
    Posts
    51
    Quote Originally Posted by 8mike View Post
    So is there a way to make it work?
    You probably need an initial hierarchy negotiation that creates a master/slave relationship between the 2 objects to allow for the coordination of the movement of the slave(s) object(s) with respect to the master. Once your slave(s) is following its master you can work out how to make it rotate independently without crashing into anything.

    For multiple slaves you could extend the hierarchy negotiation to determine the slaves following location (radius based on the total number of slaves in the formation) before merging the new object into the formation (either rotating or stationary).
    Reply With Quote  
     

  7. #7  
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    I managed to work out a hierarchy. My problem is exactly in the formulas for the circular motion. If i use uniform circular motion the radius will keep increasing as the master moves. If i use the formula I posted it loses velocity quickly or it gets out of the orbit.
    Reply With Quote  
     

  8. #8  
    Senior Member
    Join Date
    Jan 2014
    Location
    out there
    Posts
    306
    Reply With Quote  
     

  9. #9  
    Senior Member
    Join Date
    Jan 2014
    Posts
    185
    Quote Originally Posted by 8mike View Post
    I managed to work out a hierarchy. My problem is exactly in the formulas for the circular motion. If i use uniform circular motion the radius will keep increasing as the master moves. If i use the formula I posted it loses velocity quickly or it gets out of the orbit.
    I don't do this sort of thing, but you might try replacing your f(x,y) with a bump function. I'd start with something like

    f(r) = 1/(1-r), where r^2 = x^2 +y^2.

    You need a way to bring the slaves close, but not too close.

    But you also might need, additionally, an inverse-squared scaling of the velocities. Perhaps f(r) = 1/{r^2 * (1-r)} would do it.

    Then

    dx = f(r)*sin(theta)
    dy = r(r)*cos(theta)
    Reply With Quote  
     

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