Live data from Hacker News

Turns are better than radians

computerenhance.com

311–320 of 494 posts

Re: Turns are better than radians

#311
post #183

Earlier quoted context omitted.

> Am I wrong? Yes. Trigonometry is extensively taught in the US. People forget this stuff if they don’t use it. Ask some 30 year old chef in whatever country you fantasize teaches properly to compare and contrast turns vs radians and you’ll get similar responses.

I'm a 50 yo programmer. I have a CS degree. I don't even remember my college calculus much less my high school trig. I just haven't had cause to use it in my career, not as a sysadmin, not as a programmer. My son is taking calc 3 and I knew I happened to have my calc 3 notes from the mid-90s, so I pulled them out of the filing cabinet and my very carefully taken notes, my proofs, my hand drawn graphs, it was all gibb…

Thankfully you didn't publish a blog post claiming you discovered a new way to represent coordinates, and then assert that programmers should switch.

Re: Turns are better than radians

#312
post #183

Earlier quoted context omitted.

> Am I wrong? Yes. Trigonometry is extensively taught in the US. People forget this stuff if they don’t use it. Ask some 30 year old chef in whatever country you fantasize teaches properly to compare and contrast turns vs radians and you’ll get similar responses.

I'm a 50 yo programmer. I have a CS degree. I don't even remember my college calculus much less my high school trig. I just haven't had cause to use it in my career, not as a sysadmin, not as a programmer. My son is taking calc 3 and I knew I happened to have my calc 3 notes from the mid-90s, so I pulled them out of the filing cabinet and my very carefully taken notes, my proofs, my hand drawn graphs, it was all gibb…

Informally, big-O and limits have a similar smell to them, calc might have helped get some wheels turning in your head for that.

I do recall taking a "probability in CS" as an electrical engineering student -- it was pretty mind-blowing to me the extent to which the CS students did not like to talk about any continuous math. It makes sense, though, these are different specialties after all.

Re: Turns are better than radians

#313

Earlier quoted context omitted.

> Only in school exercises you can solve a differential equation by expanding a sine function into a Taylor series. > In practical physics computations, the solution of differential equations requires numerical methods that do not use the Taylor series of specific functions, even if the theory used for developing the algorithms may use the Taylor series development of arbitrary functions. I'm sorry, but you have no i…

You have replied to something that I have not said. I have said that the Taylor series of arbitrary functions have various uses, but there is no benefit in knowing which are the specific Taylor expansions of the trigonometric functions, with the exception of knowing that the first term of the sine and tangent expansions when the argument is in radians is just X. Solving physics problems using the expansion of an unkn…

> with the exception of knowing that the first term of the sine and tangent expansions when the argument is in radians is just X.

There are more terms in the expansion that you can use, that's the whole point of using an expansion...

> Solving physics problems using the expansion of an unknown function in the Taylor series has nothing to do with knowing which is the Taylor series of the sine function.

I hope you're aware that the sine function appears quite often in Physics problems.

Re: Turns are better than radians

#314
post #266

Earlier quoted context omitted.

That's an obfuscation from the blog post. If you read further down in the code that is mentioned, the actual computation of sin is done by a polynomial expansion in x (radians), not y (turns). The purpose of y is mainly in case x is more than pi, and if so, what the corresponding angle in [0,pi/4) is.

You can if you want make a polynomial in turns. The CPU isn’t going to care one way or the other. Implementations which are accurate in terms of turns even for values close to half a turn can be useful for avoiding numerical issues that sometimes pop up because π is not exactly expressible as a floating point number. These functions usually names like sinpi, cospi, etc. It would be nice if they were provided more oft…

Based on the article, CUDA has a sinpi instruction (or whatever they call them in CUDA-land). Does anyone know -- is sinpi commonly provided in the CPU assembly extension ecosystem (avx & friends)? Light googling showed me some APIs that had implementations, but I didn't dig in enough to see if they are directly implemented in assembly (this seems like the sort of info a wizard here would know about, and probably whether these types of instructions tend to be well-implemented...).

Re: Turns are better than radians

#315
post #267

Earlier quoted context omitted.

On a related note, it bothers me that there’s so much urgency to teach younger kids more and more advanced math. I use more and higher math on a day-to-day basis than practically anyone I know, but it’s very rarely even calculus, and even then it’s typically just discrete integrals or derivatives. There’s just an absolute ton of math being taught that’s going completely to waste, and it’s at the expense of the humani…

My biggest “Screw everything” moment about math was the first lecture of my numerical methods class in college when the professor said: “All that calculus you’ve been learning your whole lives? It’s useless. Carefully curated set of a few dozen problems that are doable by hand. Here’s how it’s really done for anything remotely practical” And then we learned a bunch of algorithms that spit out approximate answers to a…

When I took 400 level Real Analysis: “All that calculus you’ve been learning your whole life? It’s a lie. Those epsilon delta proofs? They were fake - none of you were smart enough to challenge us on ‘limits’. And now we’re gonna do it all again only this time it’s really gonna be rigorous.”

Re: Turns are better than radians

#316
post #276
post #259

I use vectors for everything in game programming. If I want to rotate something, Unity has this: transform.rotation = Quaternion.LookRotation(directionVector); I never touch sin, cos, pi. When I see a sin function in someone's code, my first instinct is that they're doing something wrong.

The abstraction Unity provides allows you to do neat things without fully understanding the math behind it. But if you don't also learn the math, now you are limited by what those abstractions allow you to do and by the performance cost due to the fact that these abtractions can't make good use of special-case information that would be available to you if you handcrafted the operation. It is perfectly legitimate to r…

It's super common for people to reach for trig to solve geometry problems when they should be using vector arithmetic instead, eg this answer on SO has to special-case vertical/horizontal lines, which can be avoided entirely if it didn't reach for trig in the first place.

https://stackoverflow.com/a/63673261

I think this is the sort of situation that GP is referring to.

Re: Turns are better than radians

#317
post #183

Earlier quoted context omitted.

I'm a 50 yo programmer. I have a CS degree. I don't even remember my college calculus much less my high school trig. I just haven't had cause to use it in my career, not as a sysadmin, not as a programmer. My son is taking calc 3 and I knew I happened to have my calc 3 notes from the mid-90s, so I pulled them out of the filing cabinet and my very carefully taken notes, my proofs, my hand drawn graphs, it was all gibb…

On a related note, it bothers me that there’s so much urgency to teach younger kids more and more advanced math. I use more and higher math on a day-to-day basis than practically anyone I know, but it’s very rarely even calculus, and even then it’s typically just discrete integrals or derivatives. There’s just an absolute ton of math being taught that’s going completely to waste, and it’s at the expense of the humani…

I think much of math 'education' is constructed as a filter to identify a small handful of math prodigies. The general population suffering anxiety and youth lost in the filter is seen as an acceptable sacrifice for the greater good of finding the math prodigies so those can be given a real math education.

Re: Turns are better than radians

#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

Re: Turns are better than radians

#319

Earlier quoted context omitted.

On a related note, it bothers me that there’s so much urgency to teach younger kids more and more advanced math. I use more and higher math on a day-to-day basis than practically anyone I know, but it’s very rarely even calculus, and even then it’s typically just discrete integrals or derivatives. There’s just an absolute ton of math being taught that’s going completely to waste, and it’s at the expense of the humani…

I doubt the students would actually learn humanities in the extra time allotted if it's not used for math. I remember a distinct refusal to internalize, especially in my male peers, during "English" classes.

Forget humanities. The hours a week after school that highschool students spend on calculus homework would probably be better spent socializing with their friends. They'll never be young again, wasting the time of a teenager with unproductive busywork is a horrible thing to do.

Re: Turns are better than radians

#320
Better than turns, radians, etc. is an `Angle` newtype AKA wrapper class.

It completely eliminates misinterpretation of the value, miscalculation from [angle = angle + tau*n] as all angles are normalized, is more descriptive, and in a decent language is zero-cost.

Programmers should not be using (radians: float) in modern languages which support wrapper classes

Post reply on HN