Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why use a unit complex number (2 numbers) instead of an angle (1 number)? Maybe it optimizes out the sins and cosses better — I don't know — but a cache is not a new type of number.




There's a significant advantage in using a tuple over a scalar to represent angles.

For many operations you can get rid of calls to trigonometric functions, or reduce the number of calls necessary. These calls may not be supported by standard libraries in minimalistic hardware. Even if it were, avoiding calls to transcendental can be useful.


Because rotations with complex numbers is not just rotations, its rotations+scaling.

The advantage of complex numbers is to rotate+scale something (or more generally move somewhere in a complex plane), is a one step multiplication operation.


Do you find yourself scaling things a lot in 2D physics, but not translating them? I'd think translation and rotation are more common than scaling.

If you need to support zoom, scaling shows up very frequently.

I can give an example from real life. A piece of code one of my colleagues was working on required finding a point on the angular bisector. The code became a tangle of trigonometry calls both the forward and inverse functions. The code base was Python, so there was native support of complex numbers.

So you need angular bisector of two points p and q ? just take their geometric mean and you are done. At the Python code base level you only have a call to sqrt. That simplifies things.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: