How Radians are Expressed

Hey! Enjoying melting my brain learning how do this stuff but I have question on how radians are expressed.

What’s the reason that radians are expressed as something like 4tau/9 rads instead of 2.793rads? I’m guessing because the decimal lacks accuracy but is that lack of accuracy ever relevant in a game coding situation?

We tend to express radian angles using their fractional representations because it’s much easier to mentally process what the angle is.

For example, since τ radians is a full circle, 4τ/9 radians is just 4/9 of a circle.

When it comes to programming, most calculations involving angles will be performed in radians, so it’s useful to develop that intuitive understanding of how they work.

When it comes to programming a solution, let’s look at some options;
(In the real world you wouldn’t hard code you’re numbers like this, so take it as an illustration only)

const float TAU = Mathf.PI * 2;

1. Math.Sin(Math.DegToRad(160));
2. Math.Sin((4 * Mathf.PI * 2) / 9);
3. Math.Sin((4 * TAU) / 9);
4. Math.Sin(2.793);

They all give you basically the same answer, but each one has it’s own strengths and weaknesses.

Option 1 is nice and readable for your average person who doesn’t know radians but because there’s a conversion taking place it will be slightly slower
Option 2 isn’t overly pleasant to read but it does the job quicker than option 1.
Option 3 is very readable even with a passing knowledge of radians but you need to store your own value for TAU since math libraries annoying omit it, so you’re taking up slightly more memory.
Option 4 doesn’t make much sense if you’re not familiar with radians and you also loses some precision with the decimal representation but it should still do the job. If you’re also not familiar with the sine function then you may mistake this for being in degrees, so you need to exercise more caution.

Personally, I prefer the readability and usability of option 3.

Thank you! That’s very helpful. :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms