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

Method getUnit

src/mathematics/Vector3.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
33Vector3 Vector3::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 Vector3(x * lengthInv, y * lengthInv, z * lengthInv);
43}
44
45// Return one unit orthogonal vector of the current vector
46Vector3 Vector3::getOneUnitOrthogonalVector() const {

Callers

nothing calls this directly

Calls 1

Vector3Class · 0.50

Tested by

no test coverage detected