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

Added Tau constant definitions to types.h #452

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

RolandMarchand
Copy link
Contributor

This PR adds constant definitions for Tau (𝜏), which is 2 * pi, or 360 degrees in radians.

The following definitions are added for float and double types:

  • GLM_TAU (tau)
  • GLM_TAU_2 (tau / 2)
  • GLM_TAU_4 (tau / 4)
  • GLM_1_TAU (1 / tau)
  • GLM_2_TAU (2 / tau)
  • GLM_SQRTTAU (sqrt(tau))

Note: these constants were calculated with bc, a precision calculator language. This means that the constants do not include floating point imprecision errors.

@MarcinKonowalczyk
Copy link
Contributor

Seems a bit superfluous to me. At most i'd agree with adding GLM_2PI (2*pi) since that's a commonly used constant, but others seem too specific to me, and very easy to define for any specific project one might want.

@recp recp merged commit 4141298 into recp:master Mar 19, 2025
@recp
Copy link
Owner

recp commented Mar 19, 2025

@RolandMarchand the PR is merged, thanks for your contributions 🚀

@MarcinKonowalczyk you are right but I'm going to merge this since Tau (𝜏) seems interesting and not much work except just by adding a few definitions

Maybe glm_tau() can be added to convert PI -> Tau (𝜏), one can convert angle returned by any function to tau then ( @RolandMarchand )

@aaronfranke
Copy link

aaronfranke commented Mar 19, 2025

Awesome to see this PR merged! Note that "convert any angle to tau" is not really a meaningful statement. Angles may be in terms of radians, degrees, or turns. Tau is not a measurement, but is a constant. It is the constant used to convert between radians and turns (turns * GLM_TAU = radians).

At most i'd agree with adding GLM_2PI (2*pi) since that's a commonly used constant,

The problem with that is Tau is a well-known constant, defined in dozens of languages and many tools/frameworks. It results in more readable code to use this name. Also, 2PI can be confused with 2_PI which means 2 / PI. Perhaps you can memorize the meaning in one particular library, but can you go to another and know what it means without looking at the definition? Tau is not used for any other mathematical constant, so if you see Tau and are aware of it, the meaning is unambiguous. Merging this PR with the Tau name was the right move IMO (though some of the other values like GLM_TAU_2 are debatable, likely helpful but not necessary).

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

Successfully merging this pull request may close these issues.

4 participants