Normalize
Posted: Thu Feb 28, 2013 9:28 am
In the Buoyancy tutorial, under the section "Applying simple drag" (http://www.iforce2d.net/b2dtut/buoyancy) there is a code snippet:
While I understand that calculating the Normalized value of the 'velDir' essentially divides the X and Y values of the linear velocity values by the length of the vector and updates the 'velDir' vector object, but I am unsure of what the value of 'vel' will actually be.
If the magnitude of 'velDir' is, say, 10.0, what would the value of 'vel' be? Would it be 1.0 after Normalization?
Code: Select all
//find relative velocity between object and fluid
b2Vec2 velDir = fixtureB->GetBody()->GetLinearVelocityFromWorldPoint( centroid ) -
fixtureA->GetBody()->GetLinearVelocityFromWorldPoint( centroid );
float vel = velDir.Normalize();
//apply simple linear drag
float dragMag = fixtureA->GetDensity() * vel * vel;
b2Vec2 dragForce = dragMag * -velDir;
fixtureB->GetBody()->ApplyForce( dragForce, centroid );
If the magnitude of 'velDir' is, say, 10.0, what would the value of 'vel' be? Would it be 1.0 after Normalization?