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 7785823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:19:03+00:00 2026-06-01T20:19:03+00:00

Does anyone know any c++/opengl sourcecode demos for 2D rigid body physics using runge

  • 0

Does anyone know any c++/opengl sourcecode demos for 2D rigid body physics using runge kutta?

I want to build a physics engine but I need some reference code to understand better how others have implemented this.

  • 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-06-01T20:19:04+00:00Added an answer on June 1, 2026 at 8:19 pm

    There are a lot of things you have to take care to do this nicely. I will focus on the integrator implementation and what I have found works good for me.

    For all the degrees of freedom in your system implement a function to return the accelerations a as a function of time t, positions x and velocities v. This should operate on arrays or vectors of quantities and not just scalars.

    a = accel(t,x,v);
    

    After each RK step evaluate the acceleration to be ready for the next step. In the loop then do this:

    {
       // assume t,x[],v[], a[] are known
       // step time t -> t+h and calc new values
       float h2=h/2;
       vec q1 = v + h2*a;
       vec k1 = accel(t+h2, x+h2*v, q1);
       vec q2 = v + h2*k1;
       vec k2 = accel(t+h2, x+h2*q1, q2);
       vec q3 = v + h*k2;
       vec k3 = accel(t_h, x+h*q2, q3);
       float h6 = h/6;
       t = t + h;
       x = x + h*(v+h6*(a+k1+k2));
       v = v + h6*(a+2*k1+2*k2+k3);
       a = accel(t,x,v);
    }
    

    Why? Well the standard RK method requires you to make a 2xN state vector, but the derivatives of the fist N elements are equal to the last N elements. If you split the problem up to two N state vectors and simplify a little you will arrive at the above scheme for 2nd order RK.

    I have done this and the results are identical to commercial software for a plan system with N=6 degrees of freedom.

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

Sidebar

Related Questions

Does anyone know any good tutorial about using NAnt for native code build process
Does anyone know any source of examples and templates for software requirements, build environment
does anyone know any tool for 'code generation' using MVC2? I know that ASP
Does anyone know any free provider for MySQL using the Entity Framework (Code First)?
Does anyone know any knowledge of using this: - (void) startMonitoringForRegion:(CLRegion *)region desiredAccuracy:(CLLocationAccuracy)accuracy I
Does anyone know any good solutions for automated deployment to a remote server using
Does anyone know any simple way to retrieve the country from a given IP
Does anyone know any good tool that I can use to perform stress tests
Does anyone know any good and free .NET Windows Controls Library
Does anyone know any resources (books/websites/whatever) related to parsing. I'm not so much interested

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.