Giter Site home page Giter Site logo

Comments (2)

LucasCampos avatar LucasCampos commented on August 22, 2024 1

@jayelliott at first, I agreed with you, but taking a more careful look at the code, I noticed one thing, totalInverse mass is not, as you pointed

1.0/(ma+mb)

but

ma*mb/(ma+mb)

This is correct, as reading the formulae on page 124

\Delta p_a = \frac{m_b}{m_a+m_b}
\Delta p_b = \frac{-m_a}{m_a+m_b}

and comparing with lines 112

particleMovement[0] = movePerIMass * particle[0]->getInverseMass();

and 114

particleMovement[1] = movePerIMass * particle[1]->getInverseMass();

we notice that they indeed are the same equation. Yet choosing totalInverseMass as the name of such variable was indeed an unfortunate choice.

P.S.: The latex code can be rendered here: http://www.codecogs.com/latex/eqneditor.php

from cyclone-physics.

lch32111 avatar lch32111 commented on August 22, 2024

Edit ver 4.
I think what @LucasCampos says is right on the case of resolveInterpenetration method.

In the code, Line 109 of the resolveInterpenetration
Vector3 movePerIMass = contactNormal * (penetration / totalInverseMass);
idmillington uses the division with totalInverseMass.

it means that
totalInverseMass before this code was (m_a + m_b)/ m_a * m_b.
because the code of totalInverseMass is

// The movement of each object is based on their inverse mass, so
// total that.
real totalInverseMass = particle[0]->getInverseMass();
if (particle[1]) totalInverseMass += particle[1]->getInverseMass();

which is 1/m_a + 1/m_b == (m_a + m_b) / m_a * m_b in the case of particle[1] existing.
and then with the movePerlMass variable using division with totalInverseMass,
the equation becomes m_a * m_b / (m_a + m_b).

and then if you multiply 1 /m_a(the inverse mass of object a) with this new equation,
you can get the delta(p_a).

As LucasCampos pointed out, I think the variable name should be modified for the better understandings of the codes.

However, In the case of resolveVelocity method, the situation is a little different.

At first, I thought what @snickerbockers says is right.

However, I wrote all the code of bridge demo, and tested it. and the code was not working properly.
I saw the particle suddenly bounce extremely over the sky.
After removing snickerbockers' thought, the code is working well.

So, I searched for some detail of physics in impulse equation.
And I think the point is on the real equation of impulse calculation.
Actually, I don't fully understand the equation, but Someone who is interested in this can search for it more.

Anyway, All the codes in pcontacts.cpp is working well.

from cyclone-physics.

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.