Live data from Hacker News

Turns are better than radians

computerenhance.com

471–480 of 494 posts

Re: Turns are better than radians

#471
post #318

My favourite way of handling angles was always with either unsigned char or 16bit unsigned int that was treated as 1/nth of turn. Usually in these cases cos/sin tables were pre-calculated for speed, although that need went away to an extent. As long as as the calculations wrap around on the underlying system, it makes angles much easier to manage, because angle1 + angle2 = angle3 is always within 0 to 255 or 0 to 655…

God please no, Unreal Engine 3 forced that approach which is why games derived from that engine all had wonky mouse inputs

Wonky mouse inputs? Why?

For the same number of bits, an integer representation of angle is always going to be more precise than a floating point one for angles away from 0. It's also going to be equally precise for the whole circle.

Re: Turns are better than radians

#472
post #455

As already mentioned by others, radians are not arbitrary units for angles; in fact, they are the "natural" "units", so to speak. By definition, an angle is just the ratio of a circular arc ( s ) to its radius ( r ), θ = s / r (as an exercise, imagine how to apply this definition to the angle between two intersecting lines). When the length of the circular arc equals its radius ( s = r ), the angle subtended is exact…

A radian is 1turn/2pi. It is not dimensionless. A radian, or a turn, has a dimension: angle. Saying 1radian=1 is just as senseless as saying 1m=1=$1. It's true that abstract math often drops units because some things (like Taylor series) work nicely in certain units. That doesn't make the unit meaningless. Street-Fighting Mathematics, thesis/book by Sanjoy Mahajan, shows what amazing things you can die in abstract ma…

Sorry, but this is incorrect. An angle is defined through the ratio of two objects with common units; it is dimensionless for the same reason that 5m / 5m is dimensionless. You could argue that radians should only refer specifically to angles, but your own example demonstrates how impracticable that would be: you can't sensibly Taylor expand a trigonometric function (eg, sin(x) ~ x) if the left-hand side and right-hand side have incompatible units.

Re: Turns are better than radians

#473

Earlier quoted context omitted.

I disagree. By wrapping an angle in an Angle class, the internal representation need never be exposed to the programmer. Rather than every programmer needing to read this blog post to see the performance benefits of using 'turns', instead now just a few library developers need to.

Types are just labels applied to variables. Their only power is type-checking a program to see whether every variable use is consistent. Wrapping something in a type doesn't magically change its value. Not to mention, Angle is a particularly poor name, since radians, degrees and turns are all different measures of angles. Say I have this program: x : Angle = 90 y : Angle = pi/4 z : Angle = 1/4 sin : Angle -> Real sin…

Why is Angle a poor name? The fact that radians, degrees and turns are all different ways to represent angles is exactly the point. Despite their different format, they represent the exact same thing, and sin(90 degrees) should return exactly the same as sin(1/4) or sin(pi/4).

From a mathematical perspective where people don't care about types, this is weird, but from an OOP perspective with polymorphism this is exactly right.

So in that sense, instead of storing angles as just a number where the programmer needs to keep checking whether it's in radians, degrees or turns, you should store it as an Angle object. And that object shouldn't use any approximations of pi, but understand what pi means. Angle.fromDegree(90) should be exactly, and not approximately Angle.fromRadian(4*PI).

Re: Turns are better than radians

#474
post #370
post #359

Earlier quoted context omitted.

This makes a lot of sense when you are expecting to take derivatives, integrals, or use complex numbers. In cases outside of that, radians lose their advantage over turns.

If you're not using derivatives, integrals, or complex numbers, maybe you'd be better off using Wildberger's "rational trigonometry" with quadrances and spreads instead of angles? I haven't actually tried it myself. Wildberger's motivation is a sort of ultra-strict Platonism* mixed with the desire to extend analytic geometry to fields other than the real numbers, though, so it wouldn't be surprising if it wasn't actu…

I never saw rational trigonometry, but I imagine it is mathematically overkill in another sense. When calling `sin` or `cos` in code you get back a rational approximation to the presumably irrational answer.

From what I quickly gleamed, using spreads would be really annoying to represent rotations, because you lose 'aditivity'. Two subsequent rotations with spreads a and b do not have spread `a` and spread `b`. Lots of code using trig is about rotations, so losing that feature would probably not be the nicest.

Re: Turns are better than radians

#475
post #65
post #55

Earlier quoted context omitted.

Is any number mod infinity equal to itself?

In the surreal numbers [1], the definition of division and hence modulo applies to all numbers, finite and infinite alike. And for any finite number -omega [1] https://en.wikipedia.org/wiki/Surreal_number

You might already know about it, but Ehrlich claims[1] that the Surreals form an ordered field which is a maximal hyperreal number system in NBG, and therefore all the results of non-standard analysis "work" (up to isomorphism) in the Surreals.

[1] Philip Ehrlich. "The absolute arithmetic continuum and the unification of all numbers great and small." Bull. Symbolic Logic 18 (1) 1 - 45, March 2012. https://doi.org/10.2178/bsl/1327328438 Theorem 20

Re: Turns are better than radians

#476
post #357

Earlier quoted context omitted.

I see where you're coming from, if the formulas end up having weird numbers like 535.4916 or numbers like 2.718 or 6.28318 then obviously there's something suspicious about the equation. But small correction though. You got the number wrong, it's actually much more weird than any of those mentioned. The actual equation you come to for ncos an nsin is: (-1)^(2x) = ncos(x) + i nsin(x) And yes, -1 is a very weird number…

> if the formulas end up having weird numbers like 535.4916 or numbers like 2.718 or 6.28318 then obviously there's something suspicious about the equation. Well, 2.718 is different than those numbers, because the derivative of 2.718^x is 2.178^x, which is a very interesting property of 2.718. The same cannot be said about 535.4. (6.283 is the ratio of a circle's, diameter to radius, which is just something intrinsic…

Circumference to radius.

But it really has nothing to do with the universe, except insofar as maths happen to (imperfectly) match it.

Presumably if the universe seemed to match some other maths, we would have invented that variety instead. The Greeks knew the Earth was round, yet made up plane geometry; and never touched on spherical geometry, as far as we know.

Astonishingly, the concept of the number line did not surface until 2000 years later. With the number line, school children can do on command what the best mathematicians of antiquity struggled with for centuries.

Re: Turns are better than radians

#477

I'm interested in this from the perspective of learning maths, rather than writing code (for now). I've wondered for a few years now whether teaching angles and trig using turns, rather than degrees or radians, would be better from the very beginning. Degrees are arbitrary and based on the numeric preferences of a dead culture, rather than on what's happening on the page or in 3d space. Radians seem better because th…

Radians makes the most sense just because (as others have pointed out) pi appears all over in math, and in all those places if you are working with a unit of raidans the math becomes a lot easier. In a few cases turns are easier to work with, but teaching them is a dead end to the vast majority of students who will never work in those domains, and even the few students who work in a domain where turns make sense they…

If mathematicians believed things can’t change or improve, and we have to stick with the status quo only because it’s common and popular, we’d never have had radians in the first place, we’d be stuck with degrees, no? Why assume that people can’t convert between turns and radians as needed, when we all already convert between degrees and radians all the time? Why not imagine a pedagogy that teaches turns and radians and degrees, giving students more flexibility than the current set rather than less?

Re: Turns are better than radians

#478

Earlier quoted context omitted.

This is a very good point, but it took me a minute to get what you were saying beneath the snark. Translating without the snark: There's a famous equation relating sin and cos to complex exponentiation. It also helps explain the Taylor expansions of sin and cos, which is one way to compute them and to find properties about them. It's a very important equation. It is: ix e = cos x + i sin x kazinator's point was that…

Isn’t this just changing units to suit your purpose? Same way we might use electron volts rather than volts to make the equations nice.

Yes, it's exactly that. Changing the units from radians to turns, to make your equations nicer, because turns are evidently the more natural unit.

Re: Turns are better than radians

#479
post #357

> But math never decreed that sine and cosine have to take radian arguments! That is not entirely true. It comes from the relationship between those functions and the complex numbers via the Euler formula. ix e = cos x + i sin x There may be arithmetic/numerical inconveniences, but that's not all there is to "math". Let's define ncos and nsin ("nice cos, nice sin") as follows: nsin x = sin 2πx ncos x = cos 2πx So the…

I see where you're coming from, if the formulas end up having weird numbers like 535.4916 or numbers like 2.718 or 6.28318 then obviously there's something suspicious about the equation. But small correction though. You got the number wrong, it's actually much more weird than any of those mentioned. The actual equation you come to for ncos an nsin is: (-1)^(2x) = ncos(x) + i nsin(x) And yes, -1 is a very weird number…

That version of euler's formula might make a nice case for half turns. Then it's just

(-1)^x = ncos(x) + i nsin(x)

It's obvious how to handle it for integers (an even number of half turns is 1, an odd number is -1), and the extension to real numbers aids the intuition.

Or, depending on your focus, quarter turns are very clean too:

i^x = ncos(x) + i nsin(x)

Either way, turns > radians (it's what I think in when doing most fourier kinds of work anyways!).

Post reply on HN