idmillington / cyclone-physics

The Physics engine that accompanies the book "Game Physics Engine Design"
MIT License
946 stars 264 forks source link

Type? #65

Closed xem closed 4 months ago

xem commented 4 months ago

Hello Ian, I'm reading your book and am currently wondering how the variable accCausedSepVelocity can be a real instead of a vec3 in this snippet:

https://github.com/idmillington/cyclone-physics/blob/d75c8d9edeebfdc0deebe203fe862299084b1e30/src/pcontacts.cpp#L51C10-L51C31

   // Check the velocity build-up due to acceleration only
    Vector3 accCausedVelocity = particle[0]->getAcceleration();
    if (particle[1]) accCausedVelocity -= particle[1]->getAcceleration();
    real accCausedSepVelocity = accCausedVelocity * contactNormal * duration;

You use it as a real in the rest of the function but it is computed from two vec3's multiplied with a duration, so I'm confused. Is the "*" operator a dot operator in disguise?

Thanks!

xem commented 4 months ago

I found the answer in paragraph 2.1.7 ("*" equals dot product)