I need to store 3D normal vectors, that is vectors (x, y, z)
such that x^2 + y^2 + z^2 = 1
. But due to space constraints I can only use 2 floats to store it.
So by storing only x
and y
, the third component can be computed as sqrt(1 - x^2 - y^2)
, i.e. one square root, two products and two subtractions.
What would be the most efficient way to store the vectors, so that reading them is as fast as possible, and if possible without bias towards one spatial direction?
Edit
Now using the values (a, b)
with a = x - y
and b = x + y
.