Tau.js icon indicating copy to clipboard operation
Tau.js copied to clipboard

Support TAU getting added to the JavaScript standard

Open egraether opened this issue 12 years ago • 21 comments

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!

egraether avatar Apr 24 '12 20:04 egraether

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

Joe-Z avatar Apr 24 '12 21:04 Joe-Z

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

pmw57 avatar Nov 19 '13 00:11 pmw57

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.

jankeromnes avatar Mar 19 '14 15:03 jankeromnes

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

rlidwka avatar Mar 20 '14 17:03 rlidwka

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 :)

jankeromnes avatar Mar 20 '14 22:03 jankeromnes

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.

cptaffe avatar Jun 08 '14 03:06 cptaffe

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

jankeromnes avatar Jun 30 '14 13:06 jankeromnes

Patch to firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1032203

jankeromnes avatar Jun 30 '14 14:06 jankeromnes

Awesome!

cptaffe avatar Jun 30 '14 14:06 cptaffe

Nice! Keep us updated on your progress

egraether avatar Jun 30 '14 18:06 egraether

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 avatar Nov 23 '14 06:11 lindes

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

lindes avatar Nov 23 '14 06:11 lindes

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

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

pmw57 avatar Nov 23 '14 11:11 pmw57

@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.

roboshoes avatar Nov 26 '14 01:11 roboshoes

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.

pmw57 avatar Nov 26 '14 02:11 pmw57

@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.

:two_men_holding_hands:

roboshoes avatar Nov 26 '14 18:11 roboshoes

👍

ShadSterling avatar Feb 26 '16 19:02 ShadSterling

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

yckart avatar May 10 '16 09:05 yckart

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

heyakyra avatar Oct 10 '17 16:10 heyakyra

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.

roboshoes avatar Oct 11 '17 19:10 roboshoes

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 ?

gwhitney avatar Nov 30 '22 15:11 gwhitney