Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TAU getting added to the JavaScript standard #1

Open
egraether opened this issue Apr 24, 2012 · 21 comments
Open

Support TAU getting added to the JavaScript standard #1

egraether opened this issue Apr 24, 2012 · 21 comments

Comments

@egraether
Copy link
Owner

This issue is dedicated to gather support among developers, that TAU gets added to the JavaScript standard as Math.TAU, so there is no longer the need of a library.

Show your support through leaving a comment.

Thank you!

@Joe-Z
Copy link
Collaborator

Joe-Z commented Apr 24, 2012

anything that makes my code simpler has my vote. long live TAU!

@pmw57
Copy link

pmw57 commented Nov 19, 2013

I'm finding myself always having to set Math.TAU as a constant, or to include a constant definition library to achieve something similar.

I for one would much rather work out the area of a circle with

var area = 0.5 * (Math.TAU * r) * r

because that shows incredibly clearly that you are working out the triangular area under a graph of the circumference.

To achieve something similar with Math.PI results in either confusing duplication

var area = 0.5 * (2 * Math.PI * r) * r

or an opaque formula that says little of its origin

var area = Math.PI * r * r

@jankeromnes
Copy link

Haha, I found this while searching for an ES Dicuss thread about adding Math.TAU to the standard. Then I saw who the repo owner is! Hat tip to @egraether for this suggestion.

@rlidwka
Copy link

rlidwka commented Mar 20, 2014

I found this while searching for an ES Dicuss thread about adding Math.TAU to the standard

did you find any? I saw a discussion about adding it to Dart, but nothing in es-discuss.

ps: +1 for the idea of couse

@jankeromnes
Copy link

I didn't, sadly. But there are very few constants in Math, so I'm not sure Math.TAU makes sense. Unless the JS community vouches for helping promote tau that is :)

@cptaffe
Copy link

cptaffe commented Jun 8, 2014

In the quickly expanding WebGL using Javascript community 2 * Math.PI is everywhere, and I'd much rather see Math.TAU. Tau is such an integral part of so many equations when dealing with circles, radians, and whatnot. I'm sort of wondering how it hasn't been added into the original standard, it's so easy to implement.

@jankeromnes
Copy link

This was proposed to ES Discuss a few days ago: http://esdiscuss.org/topic/math-tau

@jankeromnes
Copy link

@cptaffe
Copy link

cptaffe commented Jun 30, 2014

Awesome!

@egraether
Copy link
Owner Author

Nice! Keep us updated on your progress

@lindes
Copy link

lindes commented Nov 23, 2014

So, I've finally gotten around to tinkering with node.js, and one of the first things I tried (upon thinking that sin waves might be useful for something, and seeing a reference to Math.PI) was node -pe 'Math.TAU', which, sadly, resulted in undefined. Yes, let's please add Math.TAU to Javascript!

Meanwhile, I'm not familiar enough with JS yet... is it possible for one to add as Math.TAU before it's actually in the standard? In ruby, for example, I could simply do module Math; TAU = 2*PI; end, and then I can reference Math::TAU just as I would Math::PI. Is there something comparable in JavaScript?

@lindes
Copy link

lindes commented Nov 23, 2014

Oh, hey, looks like Math.TAU = 2*Math.PI works nicely. Is there a reason your Tau.js isn't just doing that?

@pmw57
Copy link

pmw57 commented Nov 23, 2014

The standard technique is to check it it's not already defined, before adding it.

if (!Math.TAU) {
    Math.TAU = 2 * Math.PI;
}

@roboshoes
Copy link
Collaborator

@lindes TAU.js is more of a joke trying to show that the usage of TAU might be easier in many cases over using PI.

You are quite right and simply defining it in your code via const TAU = Math.PI * 2 does the trick and really is all you rneed. (possible having to use var depending on you environment)

Still glad you found this thread though.

@pmw57
Copy link

pmw57 commented Nov 26, 2014

The usage of TAU is also makes the formulas more consistent throughout.

Using diameter for the circumference and then shifting to using the radius for area and volume is a strong indicator that the radius should be used as well in the circumference.

C = πd = π·2r = 2πr

Due to the radius being consistent now with other formulas like area and volume, we can see if 2π is easily available from those ones too.

A = πr² = ½·2πr²
Why is half used? Because that's taking the integral of the circumference, and is consistent with many other integral formulas.

V = 4/3·πr³ = 2/3·2πr³
Why two thirds? Because when comparing a cylinder and a sphere, the sphere is two thirds the volume of the cylinder. And, we can derive this from the equation of a circle, see http://www.mathalino.com/reviewer/derivation-formulas/derivation-formula-volume-sphere-integration

The improvement when using TAU

With τ = 2π we have:

C = τ·r
The circumference is directly proportional to the circle's radius.

Integrate τ·r over the radius and we get A = ½·τ·r²

Integrate the equation of a circle (x²+y²=r²) over the radius, to get V = ⅔·τ·r³

The math becomes more beautiful, and the clean clear path is easier to follow from one stage to another, when we start with the correct constants and derive the rest by simple integration.

There is nothing joke-like about these improvements. They can greatly enhance the understanding of the formulas, and the lessons learned can be applied in the same way across many other math disciplines.

@roboshoes
Copy link
Collaborator

@pmw57 thanks for the beautiful write up and the much more in depth explanation. I wanted to add that the 'joke' part of my previous message is not about the usage of TAU over PI in math, which I strongly support for reasons you have nicely explained, but rather making it a JavaScript framework. I simply meant that there is no need bringing in a 3rd party library that just defines one constant.

👬

@ShadSterling
Copy link

👍

@yckart
Copy link

yckart commented May 10, 2016

No Math.TAU in Harmony, per the meeting notes:
https://esdiscuss.org/notes/2014-07-31#5-1-math-tau

@heyakyra
Copy link

are there more ways to push for this? official channels?

@roboshoes
Copy link
Collaborator

Not sure but I don't think it's very likely to happen 😞
The argument of defining it with Math.PI * 2 is probably to easy. While I'm a strong proponent of TAU I just doubt it.

@gwhitney
Copy link

But frankly what's the argument against having Math.TAU in the standard and letting the benighted who like to see lots of unnecessary doubling in their code use if (!Math.PI) Math.PI = Math.TAU / 2 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests