Live data from Hacker News

Avoiding Trigonometry (2013)

iquilezles.org

81–90 of 92 posts

Re: Avoiding Trigonometry (2013)

#81

Earlier quoted context omitted.

Hah. I think we're and the author of both articles on the same page about this. (I had to review my implementations to be sure). I'm a fan of all angles are radians for consistency, and it's more intuitive to me. I.e. a full rot is τ. 1/2 rot is 1/2 τ etc. Pi is standard but makes me do extra mental math, and degrees has the risk of mixing up units, and doesn't have that neat rotation mapping. Very good tip about the…

If you want consistency, you should measure all angles in cycles, not in radians. Degrees are better than radians, but usually they lead to more complications than using consistently only cycles as the unit of measure for angles (i.e. to plenty of unnecessary multiplications or divisions, the only advantage of degrees of being able to express exactly the angle of 30 degrees and its multiples is not worth in compariso…

Holy shit I have to try this.

Re: Avoiding Trigonometry (2013)

#82

Earlier quoted context omitted.

If you want consistency, you should measure all angles in cycles, not in radians. Degrees are better than radians, but usually they lead to more complications than using consistently only cycles as the unit of measure for angles (i.e. to plenty of unnecessary multiplications or divisions, the only advantage of degrees of being able to express exactly the angle of 30 degrees and its multiples is not worth in compariso…

Holy shit I have to try this.

Unfortunately, IEEE Std 754 contains a huge mistake, which has been followed by some standard libraries for programming languages.

As an alternative to the trigonometric functions with arguments measured in radians, it recommends a set of functions with arguments measured in half-cycles: sinPi, cosPi, atanPi, atan2Pi and so on.

I do not who is guilty for this, because I have never ever encountered a case when you want to measure angles in half-cycles. There are cases when it would be more convenient to measure angles in right angles (i.e. quarters of a cycle), but half-cycles are always worse than both cycles and right angles. An example where measuring angles in cycles is optimal is when you deal with Fourier series or Fourier transforms. When the unit is the cycle that deletes a proportionality constant from the Fourier formulae, and that constant is always present when any other unit is used, e.g. the radian, the degree or the half-cycle.

Due to this mistake in the standard, it is more likely to find a standard library that includes these functions with angles measured in half-cycles than a library with the corresponding functions for cycles. Half-cycles are still better than radians, by producing more accurate results and being faster, but it may be hard to avoid some scalings by two. However, usually it is not necessary to do a scaling at every invocation, but there are chances that the scalings can be moved outside of loops.

Such functions written for angles measured in half-cycles can be easily modified to work with arguments measured in cycles, but if one does not want to touch a standard library, they may be used as they are.

When one uses consistently the cycle as the unit of angle, which is consistent with measuring frequencies in Hertz, i.e. cycle per second, instead of measuring them in radian per second, one must pay attention to the fact that a lot of formulae from most handbooks of physics are incorrect. Despite the claim that those formulae are written in a form that is independent of the system of units, this claim is false because many formulae are written in a form that is valid only when the unit of angle is the radian.

For example, all formulae for quantities related to rotation movements, as they are written in modern handbooks contain the "radius". This use of the "radius" creates a wrong mental model of the rotational quantities, both for students and also even for many experienced physicists.

In reality, in all those formulae, e.g. in the definition of the angular momentum, in order to obtain the correct formulae one must replace the "radius" with the inverse of the curvature of the trajectory of the movement. Thus the angular momentum is not the product of the linear momentum by the radius, but it is the ratio between the linear momentum and the curvature.

Then one must use the correct definition for the curvature. Most handbooks define the curvature as the inverse of the radius. This is a wrong definition, which is based on the non-explicit assumption that angles are measured in radians.

The correct definition of the curvature is as the ratio between rotation angle and length, for the movement, i.e. more precisely it is the derivative of the rotation angle as a function of the length of the curve on which something moves. When angles are measured in radians, the curvature is the inverse of the radius. When angles are measured in cycles, the curvature is the inverse of the perimeter. Thus with angles measured in cycles the angular momentum is defined as the product between the linear momentum and perimeter. Similarly for the other rotational quantities, like angular velocity and acceleration, moment of inertia and so on.

Re: Avoiding Trigonometry (2013)

#83
post #78

Earlier quoted context omitted.

There are many applications where instead of angles it is more convenient to use the Y to X ratio (also the Z to X ratio in 3D), i.e. to use the tangent of the angle as a scalar that encodes the direction. In 2D, using either the angle or its tangent needs a single number. The third alternative is, as others have mentioned, to use a complex number (i.e. the cos and sin couple). Any of these 3 (angle, tangent of angle…

That's right. However, one disadvantage of using the tan value (the y/x ratio) over that of (cos,sin) tuple is that the former loses information on whether the y coordinates or the x coordinate was negative. So, if you use the tan representation you have to carry that information separately. Furthermore, the code needs to correctly handle zero and infinity. Tan of the half angle takes care of the first problem and is…

It is also revealing that in Fourier series, the phase angle is represented as a sin, cos tuple and not as a scalar.

Re: Avoiding Trigonometry (2013)

#84
post #77

Earlier quoted context omitted.

If with an axiomatic system there are undecidable propositions, that is not the same with the axiomatic system being contradictory, i.e. where you can prove that a proposition is both true and false. An undecidable proposition is neither true nor false, it is not both true and false. A system with undecidable propositions may be perfectly fine, while a contradictory system is useless. Thus what the previous poster ha…

Indeed. Soundness and completeness are different things. There are two well accepted definitions of soundness. One of them is the inability to prove true == false, that is, one cannot prove a contradiction from within that axiomatic system.

They aren't completely different, because trying to achieve wine generally harms the other.

Re: Avoiding Trigonometry (2013)

#85
post #55

Earlier quoted context omitted.

Stuff like this is what really interests me in trying to imagine how differently aliens might use things that we consider to be immutable fundamentals.

personal theory: I think there's going to turn out to be a parallel development of math that is basically strictly finitist and never contends with the concept of an infinite set, much less the axiom of choice or any of its ilk. Which would require the foundation being something other than set theory. You basically do away with referring to the real numbers or the set of all natural numbers or anything like that, and…

That math exists, but it is annoying to work with.

Re: Avoiding Trigonometry (2013)

#86

Earlier quoted context omitted.

> I think this is missing the reason why these APIs are designed like this: because they're convenient and intuitive Agreed. In my view, the method the author figured out is far from intuitive for the general population, including me.

I guess the point is: How often do we really need actual angles in the code? Probably only at the very ends: input from users and output to users. Everywhere else, we should just be treating them as sin/cos pairs or dot/cross pairs. So when the user inputs an angle, immediately convert it to what the computer actually needs, store it that way throughout the computation, and then only if/when the user needs to see an…

This is how most physics/graphics engines work.

Re: Avoiding Trigonometry (2013)

#87
post #84
post #77

Earlier quoted context omitted.

Indeed. Soundness and completeness are different things. There are two well accepted definitions of soundness. One of them is the inability to prove true == false, that is, one cannot prove a contradiction from within that axiomatic system.

They aren't completely different, because trying to achieve wine generally harms the other.

True, I guess you understood what I meant, that they are different things.

Indeed, as you allude, you cannot have both in an expressive enough system.

Re: Avoiding Trigonometry (2013)

#88
post #55

Earlier quoted context omitted.

personal theory: I think there's going to turn out to be a parallel development of math that is basically strictly finitist and never contends with the concept of an infinite set, much less the axiom of choice or any of its ilk. Which would require the foundation being something other than set theory. You basically do away with referring to the real numbers or the set of all natural numbers or anything like that, and…

How would you do limits or analysis?

I think it's just a perspective shift. The main idea is that you can't ever measure a real number, only an approximation to one, so if two values differ by less than the resolution of your measurement they are effectively the same. For example consider the derivative f(x+dx) = f(x) + f'(x) dx + O(dx^2). The analysis version of the derivative says that in the limit dx -> 0 the O(dx^2) part vanishes and so the limit [f(x+dx)-f(x)]/dx = f'(x). The 'finitist' version would be something like: for a sufficiently small dx, the third term is of order dx^2, so pick a value of dx small enough that dx^2 is below your 'resolution', and then the derivative f'(x) is indistinguishable from [f(x+dx)-f(x)]/dx, without a reference to the concept of a limit.

Re: Avoiding Trigonometry (2013)

#89
post #85
post #55

Earlier quoted context omitted.

personal theory: I think there's going to turn out to be a parallel development of math that is basically strictly finitist and never contends with the concept of an infinite set, much less the axiom of choice or any of its ilk. Which would require the foundation being something other than set theory. You basically do away with referring to the real numbers or the set of all natural numbers or anything like that, and…

That math exists, but it is annoying to work with.

any particular reference to what you're thinking of? I am aware of some writings on finitist or constructivist mathematics but they have not quite seemed to get at what I want (in particular doing away with explicit infinities does not require doing away with excluded middle at all, which is what most of that literature seems to be concerned with).

Re: Avoiding Trigonometry (2013)

#90
post #88

Earlier quoted context omitted.

How would you do limits or analysis?

I think it's just a perspective shift. The main idea is that you can't ever measure a real number, only an approximation to one, so if two values differ by less than the resolution of your measurement they are effectively the same. For example consider the derivative f(x+dx) = f(x) + f'(x) dx + O(dx^2). The analysis version of the derivative says that in the limit dx -> 0 the O(dx^2) part vanishes and so the limit [f…

Yes but like I was thinking more how you'd do any kind of "and it vanishes" or even "becomes sufficiently small" with a gappy number system as it would have to pass through gaps where "undefined" non-rationals exist.
Post reply on HN