Git Product home page Git Product logo

Comments (4)

jrouwe avatar jrouwe commented on July 28, 2024

Hello,

I was looking into this and I think the code is actually correct and the article isn't. An error crept in when going from eq 12 to eq 14:

image

image

The 4 was replaced by a 2 by accident.

If you make the code in the article readable by adding newlines you can see that it does the correct thing by using (H/2)^2 = H^2/4:

float temp1 = capsuleHeight*0.5f; 
float temp2 = temp0 + hsM*(temp1*temp1 + 3.0f*oneDiv8*capsuleHeight*capsuleRadius); 

from joltphysics.

akb825 avatar akb825 commented on July 28, 2024

It seems you're right, and looking through the article comments someone else pointed out the same mistake. They mention that the sample code is correct, so it was just the final equation. Might be useful to add a comment where you reference the article mentioning the error.

I'm writing some tests for my own inertial computations, I'll see if I can write one comparing a mesh approximation of a capsule, which should hopefully fully verify whether it's correct. I also tried looking at PhysX's capsule inertia implementation, but that proved fruitless as their math is way off. (in this function if you're curious)

from joltphysics.

akb825 avatar akb825 commented on July 28, 2024

After creating a capsule mesh and computing the inertia from the mesh, I can confirm that the sample code (and correcting the equation to use H^2/4) does give the correct result. It's at least comforting to know that appears to be the only mistake made in the article.

I'll go ahead and close this issue, though as stated earlier it may be useful to have a comment noting the error in the original reference.

from joltphysics.

jrouwe avatar jrouwe commented on July 28, 2024

I'll go ahead and close this issue, though as stated earlier it may be useful to have a comment noting the error in the original reference.

Done.

from joltphysics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.