Giter Club home page Giter Club logo

Comments (12)

zOadT avatar zOadT commented on May 24, 2024 1

Hey! Thank you for reporting the issue. I did a quick bisect, the bug was introduced by commit b7ce8be80e6e4c2e71a5d5e3a08aca2676d7c990. The stack trace (at the commit) is

Uncaught TypeError: v is undefined
    transformVec2 Matrix.ts:223
    Distance Distance.ts:173
    testOverlap Distance.ts:749
    update Contact.ts:584
    updateContacts World.ts:977
    step World.ts:809

Stack trace for main:

transformVec2 Matrix.ts:236
    Distance Distance.ts:175
    testOverlap Distance.ts:743
    update Contact.ts:590
    updateContacts World.ts:978
    step World.ts:810

Will take a closer look tomorrow, I guess this should be a relatively easy fix

from planck.js.

shakiba avatar shakiba commented on May 24, 2024 1

One more option is adding combine3Vec2 function, so that we can also use it here

@zOadT Up to you, feel free to do whatever you prefer

from planck.js.

zOadT avatar zOadT commented on May 24, 2024 1

Oh yeah, combine3Vec2 is also more similar to the other matrix functions. Will open a PR tomorrow!

from planck.js.

zOadT avatar zOadT commented on May 24, 2024 1

Yes (Sorry, forgot to close it)

from planck.js.

shakiba avatar shakiba commented on May 24, 2024 1

Yes, I will in a few days, I also merged a few changes

from planck.js.

quinton-ashley avatar quinton-ashley commented on May 24, 2024 1

@shakiba It worked! Thank you :)

from planck.js.

zOadT avatar zOadT commented on May 24, 2024

The issue is caused by numeric inaccuracy. It can be solved in PolygonShape.ts by replacing

// (A)
matrix.combineVec2(center, 1, center, triangleArea * k_inv3, e1);
matrix.combineVec2(center, 1, center, triangleArea * k_inv3, e2);

with

center.x += triangleArea * k_inv3 * e1.x + triangleArea * k_inv3 * e2.x;
center.y += triangleArea * k_inv3 * e1.y + triangleArea * k_inv3 * e2.y;

It really is just a numeric issue because the issue shows up again if you set

center.x = center.x + triangleArea * k_inv3 * e1.x + triangleArea * k_inv3 * e2.x;
center.y = center.y + triangleArea * k_inv3 * e1.y + triangleArea * k_inv3 * e2.y;

and can be solved again by setting parentheses

center.x = center.x + (triangleArea * k_inv3 * e1.x + triangleArea * k_inv3 * e2.x);
center.y = center.y + (triangleArea * k_inv3 * e1.y + triangleArea * k_inv3 * e2.y);

Could it be that maybe some sizes/masses of bodies are outside of the recommend order of magnitude because they span the entire world?

@shakiba This issue wasn't present in alpha because (A) was

center.addCombine(triangleArea * k_inv3, e1, triangleArea * k_inv3, e2);

In general this seems to me to be numerically more stable because the terms being combined are probably the same order of magnitude. Shall we reintroduce a matrix.addCombineVec2 function and use it where previously addCombine was used in the entire code base? But might actually also have to check why this caused an error.

from planck.js.

shakiba avatar shakiba commented on May 24, 2024

Hmm, very interesting—thanks for reporting and investigating this!

How about assigning e1, e2 combination value to a temporary variable and then adding it to center?

from planck.js.

shakiba avatar shakiba commented on May 24, 2024

I prefer to have fewer functions in new matrix, but this seems a common use-case so I think adding a new function as you suggest is also a good idea.

from planck.js.

shakiba avatar shakiba commented on May 24, 2024

Is this resolved now?

from planck.js.

shakiba avatar shakiba commented on May 24, 2024

Thanks!

from planck.js.

quinton-ashley avatar quinton-ashley commented on May 24, 2024

@zOadT @shakiba Thank you! Could you guys make a new beta version of planck in dist? or are you waiting to release v1?

from planck.js.

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.