
Topology and complex analysis for the unsuspecting game dev - atomlib
https://gamedevnotesblog.wordpress.com/2019/12/26/compression-of-3d-unit-vectors/
======
Animats
That's an awfully complicated explanation for what seems a simple process.

The idea here is that you have a unit vector represented by three numbers, and
you want to represent it as two numbers to save space. Since it's a unit
vector, it obeys

    
    
       x^2 + y^2 + z^2 = 1
    

so if you have any two of x,y,z, you can get the third, except you need to
store its sign somewhere. Their scheme for storing the sign loses some
precision, since it maps the sphere into half the disk, costing one bit of
precision. This isn't lossless. So you could do equally well with some other
encoding to store that one sign bit.

I've seen this done for quaternions, where you have a 4-value unit vector.
Same idea.

~~~
mike_hock
I mean, the point was probably to teach some complex analysis and topology
along the way.

You could just x += 2*sgn(x) if z < 0, sacrificing the least significant bit
of x in a way that doesn't require any bit hacks (so on restoration, z < 0 iff
abs(x) >= 2, and the excess +/-2 is easy to remove from x since the real x <=
1).

~~~
gpm
If we are using floats, couldn't we just store the sign of z in the sign bit
of the exponent of x with no loss of precision since it should always be
negative for a number in [-1, 1].

Which is only possible because storing a number in [-1, 1] in a float is
wasting a bit of space, but everyone does it.

------
throwlaplace
complex analysis means to me ... analysis. cauchy-riemann, laurent series,
residue theorem, etc. i only skimmed but this looks like just complex
_numbers_.

on the other hand here's a cool use of holomorphic maps (analytic in the plane
or entire or differentiable at every point) to construct barycentric
coordinates

[https://onlinelibrary.wiley.com/doi/full/10.1111/j.1467-8659...](https://onlinelibrary.wiley.com/doi/full/10.1111/j.1467-8659.2011.02027.x?casa_token=ykAlTb57K5EAAAAA%3AzngF9nxkJeuW-
NkQgoNeI6y7LLaVR_W41uN7hr5BCzTOvOrcbP8BTXdoapjQK0PEOAiNznu1D_vj1tU)

~~~
jefft255
Having done a lot of real analysis as an undergrad, my one complex analysis
course was fairly different. We spent most of the semester proving stuff that
didn’t have any analogue in real analysis. But sure the basics are the same
and a lot of tricks from real analysis still apply.

------
contravariant
> I didn’t work out whether this bijection is a homeomorphism or not

It can't be a homeomorphism as one space is Hausdorff and the other very much
isn't.

------
tus88
Complex analysis is why I quit maths at college and focused on software
engineering :D

~~~
arkano
Complex analysis is why I stopped taking so many software engineering courses
and turned to math.

