Fastest rotation route in rapier2d

OK, I see the problem here:

This is a unit-magnitude Complex used to express rotation. It is not an angle. You need to work in terms of vectors, not angles. The number 360 will not appear in your code (nor 2π), and you don't need to wrap to 360. To change direction, multiply another unit complex with it (which is equivalent to adding angles).

If you really want to convert to angle, call https://docs.rs/num-complex/0.4.4/num_complex/struct.Complex.html#method.to_polar — but most operations can be expressed in terms of the complex number, often more elegantly (because there is no discontinuity at 360-0).

3 Likes