Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 979691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:15:31+00:00 2026-05-16T04:15:31+00:00

I am trying to create a dynamic body that orbits around a static body

  • 0

I am trying to create a dynamic body that orbits around a static body in Box2D.
I have a zero-gravity world, and a DistanceJoint that connects the two bodies. I have removed all friction and damping from the bodies and the joint, and am applying an initial linear velocity to the dynamic body. The result is that the body starts orbiting, but its velocity diminishes over time – which I do not expect in a zero gravity environment without friction.

Am I doing something wrong? Should the linear velocity be recreated at each step, or can I delegate this work to Box2D?

Here is the relevant code:

// positions of both bodies

Vector2 planetPosition = new Vector2(x1 / Physics.RATIO, y1 / Physics.RATIO);
Vector2 satellitePosition = new Vector2(x2 / Physics.RATIO, y2 / Physics.RATIO);


// creating static body

BodyDef planetBodyDef = new BodyDef();
planetBodyDef.type = BodyType.StaticBody;
planetBodyDef.position.set(planetPosition);
planetBodyDef.angularDamping = 0;
planetBodyDef.linearDamping = 0;

planetBody = _world.createBody(planetBodyDef);

CircleShape planetShapeDef = new CircleShape();
planetShapeDef.setRadius(40);

FixtureDef planetFixtureDef = new FixtureDef();
planetFixtureDef.shape = planetShapeDef;
planetFixtureDef.density = 0.7f;
planetFixtureDef.friction = 0;

planetBody.createFixture(planetFixtureDef);

// creating dynamic body

BodyDef satelliteBodyDef = new BodyDef();
satelliteBodyDef.type = BodyType.DynamicBody;
satelliteBodyDef.position.set(satellitePosition);
satelliteBodyDef.linearDamping = 0;
satelliteBodyDef.angularDamping = 0;

satelliteBody = _world.createBody(satelliteBodyDef);

CircleShape satelliteShapeDef = new CircleShape();
satelliteShapeDef.setRadius(10);

FixtureDef satelliteFixtureDef = new FixtureDef();
satelliteFixtureDef.shape = satelliteShapeDef;
satelliteFixtureDef.density = 0.7f;
satelliteFixtureDef.friction = 0;

satelliteBody.createFixture(satelliteFixtureDef);

// create DistanceJoint between bodies

DistanceJointDef jointDef = new DistanceJointDef();        
jointDef.initialize(satelliteBody, planetBody, satellitePosition, planetPosition);
jointDef.collideConnected = false;
jointDef.dampingRatio = 0;

_world.createJoint(jointDef);

// set initial velocity

satelliteBody.setLinearVelocity(new Vector2(0, 30.0f)); // orthogonal to the joint
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:15:32+00:00Added an answer on May 16, 2026 at 4:15 am

    Physically, you are correct. Conservation of energy should ensure that the speed of the body remains constant.

    However, Box2D cannot perfectly represent physics. There will be a small error in every frame, and these errors add up. I don’t know how Box2D handles joints, but if it projects the object’s position onto a circle, this would cause the distance travelled during a frame to be slightly smaller than it would have been without the joint.

    Bottom line: it’s not reasonable to expect the speed to remain exactly the same as what you started with, and you will need to compensate. Depending on your needs, you can either set the velocity manually each frame, or maybe use a revolute joint, anchored on the planet, with a motor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a dynamic hyperlink that depends on a value passed
I am trying to create a dynamic link that will let the user delete
I'm trying to create a dynamic QSlider that accepts a QVector of integer values
Lets say that I have to do this dynamic PUT request: http://mydomain.com/api/5?value=66 The body
I'm trying to create Dynamic SVG graphics, it is my understanding that the only
I am trying to create a dynamic table that is being built based on
I'm trying to just create a listview on a static page. Nothing dynamic at
I am trying to create a dynamic image that will be created from PHP
I am trying to create a dynamic sidebar in zend framework. I have googled
I am trying to create dynamic pages without creating new files and getting the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.