3 ms·
Topology and complex analysis for the unsuspecting game dev
- Animats 7y agoThat'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 7y agoI 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 7y agoIf 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.
- layoutIfNeeded 7y ago>I've seen this done for quaternions, where you have a 4-value unit vector. Which has an additional benefit, namely that the unit quaternions q and -q represent the same rotation, so there's no need to store the sign bit.
- tus88 7y agoComplex analysis is why I quit maths at college and focused on software engineering :D
- arkano 7y agoComplex analysis is why I stopped taking so many software engineering courses and turned to math.
- jefft255 7y agoI enjoyed my complex analysis course quite a bit, but I was lacking motivation a bit because the applications in CS were not as obvious to me, compared to real analysis. Maybe I lacked imagination however :D
- contravariant 7y ago> 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.
- throwlaplace 7y agocomplex 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.2011.02027.x?casa_token=ykAlTb57K5EAAAAA%3AzngF9nxkJeuW-NkQgoNeI6y7LLaVR_W41uN7hr5BCzTOvOrcbP8BTXdoapjQK0PEOAiNznu1D_vj1tU https://onlinelibrary.wiley.com/doi/full/10.1111/j.1467-8659...
- jefft255 7y agoHaving 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.