Code Monkey home page Code Monkey logo

Comments (4)

mmacklin avatar mmacklin commented on July 23, 2024

Hi there,

Thank you for the detailed repro case. I was able to confirm your results here, and I believe this is an issue of loss of numerical precision.

When using a spacing of 0.15 there are ~4k particles in the shape matching constraint, when using spacing of 0.1 there are ~13k particles in the constraint (count scales with the inverse cube of the spacing). Because shape-matching has to compute a sum over all particles for the center of mass and moment matrices, it eventually runs out of numerical precision, and results in numerical drift in some arbitrary direction.

Unfortunately there is no easy solution to this other than to limit the number of particles in an individual constraint. One workaround could be e.g.: overlapping multiple shape-matching constraints and increasing the iteration count to achieve the desired stiffness.

We are looking at supporting triangle-based collision detection in the future, which would avoid some of these problems by decoupling the particle discretization from the shape representation.

Cheers,
Miles

from flex.

Hurleyworks avatar Hurleyworks commented on July 23, 2024

Hi Miles,

Thanks for the quick response! Triangle-based collision detection would be a great feature to have.

One other problem I'm having is Flex seems to be calculating the center of mass differently than my application does. I just add up all the vertex positions and multiply by the inverse of the point count. But the value I get doesn't match Flex. Could you tell me how Flex calculates the center of mass?

int pntCount = triMesh.getVertexCount();
for (int i = 0; i < pntCount; i++)
{
	Vector3d pnt = points.row(i);
	pBody->t.centerOfVertexMass += pnt.cast<float>();
}
pBody->t.centerOfVertexMass *= 1.f /(float)pntCount;

from flex.

 avatar commented on July 23, 2024

Hi @Hurleyworks ,
maybe you're looking for function CalculateRigidCentersOfMass() in helpers.h (in the "demo" folder)

from flex.

Hurleyworks avatar Hurleyworks commented on July 23, 2024

Thanks. Looks like that's new in 1.2 and I've been using Flex 1.1 until 1.2 is out of beta.

from flex.

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.