Say I have a normalized vector but I don't know what the z coordinate is. How can I retrieve the normalized z coordinate while preserving the existing x and y coordinates.
For example:
X: -0.361
Y: 0.361
Z: ?
The length of just x and y is 0.510531
len = sqrt((ax * ax) + (ay * ay)) -- 0.510531
Thanks!
What does it mean to have a normalized vector? It means that
|Vx|^2 + |Vy|^2 +|Vz|^2 = 1
. So, from standard algebra, it follows that|Vz| = sqrt(1 - |Vx|^2 - |Vy|^2)
, which implies thatVz
can take 2 values, negative and positive ofsqrt(1 - |Vx|^2 - |Vy|^2)
And btw, the answer is the same in all programming languages ;) Math has nothing to do with C++.