Hi everyone! Today I’m proud to announce, Commander! It adds tons of new functions for your day to day use in Codea, Here are some of them so far:

button(name, width, height, x, y) - Useful for game menus and other game features.


rt(number, power) - Finds the root of a number, for example. if you plug in 3 in the “power” slot, it will give you the cube root of said number.

cbrt(number) - Finds the cube root of a number

And much more!

Download for it will be up soon, once I pack it into a auto installer :slight_smile:

Also, feel free to give me suggestions for some functions, I’m running out of ideas fast.

Okay, I’m curious. What is math.tau()?

Snatched this from the wiki, its better at explaining it then me:

In 1958 Albert Eagle proposed replacing ? by ? = ?/2 to simplify formulas. However, no other authors are known to use tau in this way. Currently, some people use a different transcendental number for tau’s value, ? = 6.283185307179586… = 2?. To them, ? seems to be more natural than ?, as it is the ratio of a circle’s circumference to its radius rather than its diameter and ? simplifies many formulas. Proposals to celebrate this number, because it approximately equals 6.28, by making 28 June “Tau Day” and eating “twice the pie”,[154] have been reported in the media. However the use of ? has not made its way into current scientific discussion

Oh dear, I was afraid of that!

There is no logic at all in having a special constant for 2π.

Hi @Andrew_Stacey ! Is there any rationnal (but historical reasons) for having chosen pi rather than 2pi? Except e^(i.pi)=-1 ? One turn is 2.pi.

@Andrew_Stacy Are you suggestion I should, remove it from my functions? <):slight_smile:

@Prynok No, I’m not suggesting that you remove it. Just that I don’t think that it’s something worth making a special constant for so if you didn’t have it then I would say not to bother putting it in. But as you already have it in then leave it there.

I’m with Albert Eagle on this one. I think that 2π is a stupid choice but π/2 actually has some reason for being the “special” angle.

@Jmv38 I understand that it comes from the fact that it is much easier to measure the diameter of a circle than its radius so the ratio of circumference to diameter is more directly useful than the ratio of circumference to radius. Euler’s formula, e^{i π}, came much much later.

@Prynok Why call a function to calculate a value when you can use the same code that’s in the function to get the same value and use less code. Or instead of making a function, just set Tau=2*math.pi and use Tau in any calculations. I say remove the function and just set Tau.

function math.tau() -- function to return tau
   return 2*math.pi
c=math.tau()*r   -- code using function

c=2*math.pi*r  -- code just doing calculation

Tau=2*math.pi  -- set Tau to value
c=Tau*r  --code using Tau

*dave1707 that’s exactly what I’m doing :slight_smile:

@andrew_Stacey thanks for your reply.
However i dont buy your explanation: circles that you want to measure the diameter do not exist in nature. What exist however, is circles man-made. People often made circles with a rope and a stick in the center, to draw a circular fence for instance. The rope gives you the radius, not the diameter. So it is easier to know the radius than the diameter. They needed to know the perimeter then to know how much logs they will need to complete the fence.
I think there is certainly a reason for pi rather than 2pi, but i have doubts about the explanation you suggest.

@Prynok - I think the question is why you’d bother including trivial one line functions like tau. The same goes for getting the root of a number, which is just a^(1/b), or the cube root, which is the same formula and doesn’t need its own function, IMHO.

If other Codea users are like me, then they don’t like to have to include external libraries of code unless they are really necessary. That’s perhaps why a library of functions you could easily write yourself doesn’t sound so exciting.

However, these may be bad examples, so don’t let us stop you publishing your function library. You may well have some gems we will be very glad to use.

@Jmv38 - I guess the choice of pi is because it is a special number. Why wouldn’t you factor the two out first? Pi is used in all sorts of things.

@Prynok You made a function to return 2 * ?, therefor the syntax is math.tau(), when you could just set a constant, math.tau = 2*math.pi, and have the syntax be math.tau.


+1 @Ignatz

@ignatz exactly. But what is so ‘special’ about pi? Coulnt we have choosen 2pi as the special number instead? I am just curious about that kind of things. Sometimes there is a nice random story behind. Sometines there is a deep law of nature. I like both!

@Ignazts Exactly! Thats why I made it, its suppose to be “easily written.”

The reason you would want to use it is because its a time saver, for example, why make a clock for your game, when there is already code for that clock?

The reason could be water tanks: they were cilinder shape. So their volume is height x surface, and surface is pi x r^2! It is very important to know exactly the volume of water you have in your tank when the dry season is coming!

@Jmv38 Except that I would imagine them to count in fractions of a full water tank. So they know they need a full water tank to last 3 months, whereupon if it is half full then can only last 1.5 months. No need to know the exact volume.

I really do think that when measuring, the diameter is easier than the radius.

As for a deep law of nature, with regard to π versus 2π then there is none. The sole argument for 2π is “it makes the formulae nicer”. There is a reason to choose π/2 instead of π that has more to do with deep concepts: the notion of orthogonality is incredibly important and that is to do with π/2.

Why do we use pi or 2 * pi or any other value, because it’s easy for us to do that. Universal constants don’t have values, WE assign values to them. I’m sure when the universe creates a star, it doesn’t try to figure out it circumference or volume based on pi or 2 * pi, it just happens, it’s the law. So what you use is based on what you want to use. If you want to use c=pi * d or c=2 * pi * r, or c=1.89 * s-fg/j, it doesn’t matter because the answer is the same. We assign values to variables, the universe doesn’t. The answers will be what they are no matter what we use.

@Prynok Looking forward to seeing the whole library. I’m sure that the subject of the last dozen or so messages is only a small part of the package.

@Andrew_Stacey thanks for the insight. After all, you may be right about the diameter: the people who build the tank know the radius, but the people who come 10 or 100 year later to repair it must measure it, and then the diameter is easier than the radius.
@Dave1707 your are perfectly right. But… great insight of the univeral laws have come from noticing some strange coincidences in coupling values. Units make sense, and sometime expressing a value in the good units reveals the physical origin of this value.