3 ms·
Everyone should use vector methods and shy away from transcendental functions to the extent possible. It is usually (but not always) possible to reframe proble
by jacobolus 8y ago
Everyone should use vector methods and shy away from transcendental functions to the extent possible.
It is usually (but not always) possible to reframe problems in such a way that exponentials (including sine/cosine/tangent) and logarithms (including arcsine, arctangent, ..) are unnecessary.
Vector methods are much faster, have fewer weird edge cases, are less subject to rounding error, etc.
As an example: if you want to store a planar vector, use a pair of coordinates instead of an angle measure and magnitude. If you want to store an 2d orientation or rotation, still use a pair of (x, y) coordinates on the unit circle instead of angle measure (which is a logarithmic quantity). If you want to reduce your pair of coordinates to a single number, use the stereographic projection, which only requires division.
- westoncb 8y agoWould you mind expanding on the idea that an angle measure is a logarithmic quantity and that sin/cos/tan are exponentials (or providing a phrase I could google)? I've never come across a formulation/characterization like that, and it sounds useful...
- jacobolus 8y agoYou can break the exponential function into the part acting on a scalar and the part acting on a bivector, and then furthermore break those into even and odd parts: exp(ρ + θi) = (cosh ρ + sinh ρ)(cos θ + i sin θ) The angle measure in the above is the θ part. The “linear space” expression of the orientation/rotation is a 2-dimensional quanitity cos θ + i sin θ. Or if you start with the 2-coordinate version x + iy, where x^2 + y^2 = 1, you can find the angle measure by taking the natural logarithm, imag(log(x + yi)). Rotations are naturally a multiplicative concept. If you have a rotation a + bi and a rotation c + di, then you can compose them like (a + bi)(c + di) = (ac - bd) + (ad + bc)i (you might recognize this as the the “angle sum” identities from high school trigonometry class). The idea of the logarithm is that you can convert a multiplicative structure into an additive one. So if you have rotations Q and R, you could normally compose them like QR, but as an alternative you can use a log-space representation (angle measure): QR = exp(log(Q) + log(R)). A rotation inherently comes with an orientation. The i (“imaginary unit”) is in my opinion properly thought of as a bivector, oriented like a plane. When we express something as a scalar-valued angle measure, we have stripped the orientation out.
- twic 8y agoThanks for this - i have studied very little maths, so even this perhaps quite basic stuff is like magic for me! I love the revelation that log/exp shifts between Cartesian and (log-)polar meanings of complex numbers. That's enormously satisfying for some reason. I note that the pattern in multiplying rotations also comes up if you do it with matrices: a -b c -d ac-bd -(ad+bc) b a . d c = ad+bc ac-bd Does something similar happen with quaternions / geometric products in 3D?
- jacobolus 8y agoTaking 3D rotations into log space gets tricky. 3D rotation is not commutative, so if you have two quaternions Q and R, you can’t in general say that QR = exp(log(Q))exp(log(R)) = exp(log(Q) + log(R)). That identity only holds if the bivector (“imaginary”) parts of Q and R are oriented the same way in space, i.e. are scalar multiples of each-other. Otherwise in general exp(log(Q))exp(log(R)) ≠ exp(log(R))exp(log(Q)). The log space version is still useful though if you want to e.g. take the nth root of a spatial rotation.