In the Doom engine, angles are used to describe directions, such as which way a character or object is facing.

Internally, angles are stored as 32-bit unsigned integer values, with zero representing east, or toward the right edge of the map. In this system, commonly referred to as "binary angle measure," increasing values represent angles increasing counterclockwise, using the full range of 32-bit unsigned precision to represent one full circle. Thus, north is represented (in hexadecimal) by 0x40000000, west by 0x80000000, and south by 0xC0000000. Northeast (45 degrees) is 0x20000000. Note that angle values can be added and subtracted, and the results will be automatically normalized; they will be between zero and just less than one full circle, because unsigned arithmetic is performed modulo the 32-bit word size.

The 32 bits can be considered as a fraction of a circle, that is, as a binary fraction with an implied decimal point at the far left. Also, if an angle value is considered as a signed quantity, then negative values represent rotation in the opposite (clockwise) direction. The value closest to one degree in this system is 0xb60b60.

Fine angles[edit]

The trigonometric functions sine, cosine and tangent are implemented using lookup tables. The angle value is compressed into an index for use with these tables by shifting down 19 bits, resulting in a value between 0 and 8191 referred to as a "fine angle." The resulting accuracy is mostly adequate for gameplay and rendering purposes. While computationally cheap in terms of instructions, this method does have an associated cache penalty, however, due to the size of the lookup tables involved.

Note that shifting right 19 bits truncates the angle value by no more than 360/8192 = 0.044 degrees.

Angles in WADs[edit]

Thing angles in WAD files are stored as 16-bit short values representing arc degrees anti-clockwise from West.

Compass point Degrees
South West 45°
South 90°
South East 135°
East 180°
North East 225°
North 270°
North West 315°

Byte angles[edit]

In the Hexen map format and in ACS scripts, particularly in the arguments of linedef specials, angles are often stored as a single unsigned byte ranging from 0 to 255. Because this format represents fewer than 360 distinct values, some accuracy is sacrificed. The following formulas can be used to convert between degrees and byte angles for numbers between 0 and 359:

  • bangle = (degrees * 256) / 360
  • degrees = (bangle * 360) / 256

Depending on the context, values 0 and 255 may have special meanings. For rotating polyobjects, 0 means to rotate exactly 360 degrees, while 255 means to rotate perpetually.

Flat rotation[edit]

ZDoom and compatible source ports such as the Eternity Engine allow flats to be rotated. Following a convention adapted from the Build engine, these angles range from 0 to 359, starting with 0 toward the north, and progress in a clockwise direction, contrary to the usual Doom engine coordinate system.