schteppe / p2.js

JavaScript 2D physics library
Other
2.63k stars 329 forks source link

Jacobian Entry #291

Open ghost opened 7 years ago

ghost commented 7 years ago

What is the point about Jacobian Entry, why it has to be six-element array?

I know that 4 elements are for bodyA velocity, and bodyB velocity 2 elements are for bodyA angularVelocity and bodyB angularVelocity

but why it has to be G[6] instead of:

G = {
    av: vec2.create(),
    bv: vec2.create(),
    aav: 0,
    bav: 0
};

As far as I can see p2 use some temporary vec2 to assign G[0] and G[1] etc. for calculations. But it would be cleaner with G as object shown above.

schteppe commented 7 years ago

It doesn't really have to be an array... It just happened to become like that when I first wrote it. In another project I worked on, we used a JacobianEntry class. I think bullet has such class too.