Live data from Hacker News

Turns are better than radians

computerenhance.com

281–290 of 494 posts

Re: Turns are better than radians

#281
A lot of people are getting hung up on the "math never decreed" sentence (not entirely wrongly since it's basically false, and surprising for Casey who has probably forgotten more linalg than I'll ever know), but that's not really the point of the article.

The point is that notationally, turns seem to read better in most code that isn't doing analysis. I'd say this points more to a flaw in our languages than in our function definitions. Of the major general-purpose languages I think only C++ has really taken a shot at implicit unit conversion, which would let you safely and correctly sum a `turn facing` and `degrees delta` and pass the result to a `float sin(radian x)` function and statically ensuring your dimensions remain correct.

Everything else I can think of either makes newtypes too complicated to define, lacks conversion overloads (or more likely lacks operator overloads entirely), or refuses to let you do them implicitly. C++'s approach is certainly too general, but is it really impossible to corral such behavior in a way that's both safe and convenient?

Re: Turns are better than radians

#282
post #247
post #202

Earlier quoted context omitted.

By far the most annoying myth I face when trying to discuss the pros and cons of various education techniques is the pervasive idea that everybody is a magical knowledge sponge and will go to their grave still remembering how to integrate by parts and every detail about some particular battle they covered in seventh grade, and therefore, if we slightly tweak a curriculum plan to drop something that was included on th…

Think it's part of the equality/blank-slate myth that everyone is the same and has the same potential and natural abilities.

Actually, it's almost entirely the opposite—the idea that students are a "sponge" that can soak up knowledge perfectly is then taken directly to mean that some students are better at soaking up / retaining knowledge then others, and that the "smart" kids who do the best on the tests are the ones who are going to retain the knowledge the best. And then the ones that were the best knowledge-sponges will eventually go on to become the next generation of teachers, since they know the most information. Whereas for most kids it's completely the opposite—they memorize the information in their short-term memory without understanding the fundamentals, they do great on the tests, and then they forget all of it immediately. But they stand out from their peers as better students, because they're able to play the "game" of school better and optimize for being a knowledge-sponge that will absorb the most information as possible and forget it as quickly as possible.

Re: Turns are better than radians

#283

Earlier quoted context omitted.

The writer don’t seem to realise that radian is not an arbitrary unit but a dimensionless one which is defined so that 1rad is actually just 1. Reading the submission and the comments here, I’m under the impression that trigonometry is not extensively taught in middle schools and high schools in the USA. While I’m slightly envious you might not have to suffer developing powers of cosine and sine but that would explai…

>I’m under the impression that trigonometry is not extensively taught in middle schools and high schools in the USA Basic trig is taught in middle school, but exclusively using degrees. Advanced trig is optional in high school if you take the "hard math" track.

Wow. You people went to crap schools. We got the derivation of modern trig functions w/ maclauren/Taylor series in 9th grade (though yeah... that was the "hard core math track".) And a year of proofs and derivations in 11th grade. Quaternions and their application in physics was 12th grade.

Re: Turns are better than radians

#284
post #245

Earlier quoted context omitted.

When have you ever used the Taylor series of sine and cosine for anything (outside school) ? When you approximate functions by polynomials, including the trigonometric functions, the Taylor series are never used, because they are inefficient (too much computation for a given error). Other kinds of polynomials are used for function approximations. The Taylor series are a tool used in some symbolic computations, e.g. f…

> When have you ever used the Taylor series of sine and cosine for anything (outside school) ? I've used them a few times, mostly in the embedded space, and mostly in conjunction with lookup tables and/or Newton's method, but yes I've absolutely used them outside school (years ago, I forget the exact details). - implementing my own trig functions for embedded applications where I wanted fine control over the computat…

I agree that using the Taylor series can be easier, especially during development, mainly because convenient tools for generating approximation polynomials or other kinds of approximating functions are not widespread.

However, the performance when using Taylor series is guaranteed to be worse than when using optimal approximation polynomials, according to appropriate criteria.

Still I cannot see when you would want to use the Taylor series of the trigonometric functions, even if for less usual functions it could be handy.

There are plenty of open-source libraries with good approximations of the trigonometric functions, so there is no need to develop one's own.

In the case of a very weak embedded CPU there is the alternative to use CORDIC for the trigonometric functions, instead of polynomial approximations. CORDIC can be very accurate, even if on CPUs with fast multipliers it is slower than polynomial approximation.

Re: Turns are better than radians

#285

Earlier quoted context omitted.

Sure, but circles are geometric too :)

Absolutely, but IMO circles have as little to do with sin and cos as triangles do :-)

That seems ahistoric as per the meaning of the word. "Sine" is derived from the Sanskrit word for 'chord' as per its initial usage in determining the length of straight line segments between two arbitrary points on a circle.

Re: Turns are better than radians

#286

Earlier quoted context omitted.

So which programming language makes sense to you? Dare I say… Rust?

Yes, Rust does indeed and a long time before that it was Pascal. I really love Pascal's syntax, it makes a lot of sense when you approach it with a math background. - '=' is for equality only - assignment is ':=' which is the next best symbol you can find in math for that purpose - numeric data types are 'integer' and 'real', no single/double nonsense - 'functions' are for returning values, 'procedures' for side effe…

It sounds like you just don’t like C — a perfectly reasonable position — not that you don’t understand it.

Re: Turns are better than radians

#287

I’m surprised game engines do conversion from degrees to radian to call trigonometric functions. I would have called that bad code in an industrial context. We did everything in radians and converted to degrees only for displaying and input. It was a lot more natural from us because we are a lot more familiar with radians anyway. I don’t think I have used degrees often since starting high school twenty years ago.

Most game engines work in radians under the hood and expose degrees in the UI but still need to glue the UI values to the API which is the code seen in Casey’s Godot example the full context of which is a color picker and h has already been converted from degrees. Godot itself has a bunch of the API in degrees which is pretty bleugh.

It's for convenience of developing tooling. Because the only thing harder than re-framing all of mathematics so that sine and cosine are properly defined in terms of turns would be teaching artists and level designers to believe that a full turn is 2π radians instead of 360 degrees.

Re: Turns are better than radians

#288

Earlier quoted context omitted.

>I’m under the impression that trigonometry is not extensively taught in middle schools and high schools in the USA Basic trig is taught in middle school, but exclusively using degrees. Advanced trig is optional in high school if you take the "hard math" track.

> Advanced trig is optional in high school if you take the "hard math" track. This depends on the state. NYS absolutely requires everyone to learn "advanced trig" in high school.

I think I would have put the quotes around "learn."

I don't think every high school student can master advanced trig.

Re: Turns are better than radians

#289
I think this whole comment thread is missing the forest for the trees.

The forest here is: know what abstractions your dependencies use and be ready to break your own when you need more speed. This is a vital skill for game developers, where every cycle tends to matter.

Re: Turns are better than radians

#290
post #271

Earlier quoted context omitted.

If you differentiate sin(x) with respect to x then you get cos(x), but only if your trig functions are using radians. Any other unit results in an extra coefficient appearing. That’s not an insurmountable problem, but radians are the fundamental unit here, not just an arbitrary choice.

I could forget something but sin'(ax) = cos(ax). If a is a constant factor.

You need to apply the chain rules, ie

    sin'(ax) = a cos(ax)
Post reply on HN