Comments (2)
@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.
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)
- Buoyancy force appears to be calculated incorrectly HOT 15
- how to find angular velocity HOT 1
- Contacts.cpp doesn't contain implementation of applyImpulse declared in Contacts.h
- Misnomer in Rigid Body HOT 1
- Questions of calculateContactBasis() of The contacts.cpp HOT 2
- Unclear variable names in contactPoint(...) in collide_fine.cpp HOT 4
- Question: Restitution causing explosive forces with friction HOT 2
- Wrong order?
- wrong calculation of total inverse mass HOT 1
- typo in contacts.h
- Does not compile for VS2019 HOT 1
- DELETE THIS
- Why dividing core.h and core.cpp?
- the implmentment of void setOrientation(const Quaternion &q) need to be transposed
- Issue with Collision Box - no rest pose is reached HOT 3
- Missing `AngledAero` force generator implementation
- Question regarding calculateDesiredDeltaVelocity
- Formula 6.5, missing factor 2
- Type? HOT 1
- Why is q present as a parameter and never used in body.cpp > _transformInertiaTensor?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cyclone-physics.