MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / getUnit

Method getUnit

src/mathematics/Vector2.cpp:33–43  ·  view source on GitHub ↗

Return the corresponding unit vector

Source from the content-addressed store, hash-verified

31
32// Return the corresponding unit vector
33Vector2 Vector2::getUnit() const {
34 decimal lengthVector = length();
35
36 if (lengthVector < MACHINE_EPSILON) {
37 return *this;
38 }
39
40 // Compute and return the unit vector
41 decimal lengthInv = decimal(1.0) / lengthVector;
42 return Vector2(x * lengthInv, y * lengthInv);
43}
44
45// Return one unit orthogonal vector of the current vector
46Vector2 Vector2::getOneUnitOrthogonalVector() const {

Callers 14

drawHeightFieldShapeMethod · 0.45
initBeforeSolveMethod · 0.45
updateBodiesStateMethod · 0.45
raycastMethod · 0.45
testCollisionMethod · 0.45
testCollisionMethod · 0.45
testCollisionMethod · 0.45
testCollisionMethod · 0.45

Calls 1

Vector2Class · 0.50

Tested by

no test coverage detected