• Nothing
  • About
Menu

Asher Einhorn

  • Nothing
  • About
radians.gif

Understanding and working with radians

June 19, 2015

The following is part of an ongoing series of basic tutorials for gameplay scripters. Note also that this symbol - Π is Pi, but the font this site is using makes it look a little odd in my opinion.

Radians are a subject that confuses some when the first start programming, and because of this they are often avoided. However, they are a very simple concept that can be extremely useful when understood. Not to mention that many libraries provide functions that return radian values, so it’s important to know how to work with them.

Ultimately they are most useful to us when using trigonometric functions which make up our mathematical bread and butter as gameplay scripters.

The basics

Radians are the standard units for measuring angles. There are 2 Π radians in one circle. In other words there are just over 6 radians in the angle of a circle. If you trace along the edge of a circle the length of its radius and mark the start and end points - the angle between those points is one radian.

Conversion

We know that 2 Π radians = 360 degrees. So we know that Π radians = 180 degrees. We can then of course see that 1 radian is equal to 180 degrees / Π and this is what we use to convert the values between degrees and radians.

Radians to Degrees

Sudocode
ourRadianValue * (180 / Π)

Unity C#
ourRadianValue * Mathf.Rad2Deg

UE4 Blueprints
'Radians To Degrees' node

Degrees to Radians

Sudocode
ourDegreeValue / (180 / Π)
But because multiplication is less expensive and safer when programming we instead use:
ourDegreeValue * (Π / 180)

Unity C#
ourRadianValue * Mathf.Deg2Rad

UE4 Blueprints
'Degrees To Radians' node

In Scripting Handbook
← Strongly vs Weakly typed languagesScripting languages vs programming languages →
Twitter
  • RT @CKapmeh: Sunday Capilla San Bernardo / Nicolás Campodonico https://t.co/V56q7uftPf
    May 28, 2017, 10:42 AM
  • Crunch dadaism. Come to @Naughty_Dog and experience the highs of creative culture. https://t.co/9yMPcTdiYA
    May 27, 2017, 9:33 AM
  • Crunch garden #gamedev Avocado, Lemon and Peppers. From right to left. https://t.co/jtZXeWDEgh
    May 27, 2017, 9:31 AM
  • Working with a migraine two days in a row is quite possibly the most unpleasant thing in recent memory.
    May 26, 2017, 3:36 PM
  • Sure is fun to have a night off! #PS4share https://t.co/WMcEMY5yWE
    May 21, 2017, 7:59 PM
  • The EU/US PSN account conflict is an ongoing nightmare. Looks like I'm not playing anything tonight after all.... pain!
    May 21, 2017, 7:49 PM