new:units

This shows you the differences between two versions of the page.

Both sides previous revision Previous revision | |||

new:units [2018/02/17 03:53] korshun |
new:units [2018/02/17 14:06] (current) korshun |
||
---|---|---|---|

Line 1: | Line 1: | ||

====== Unit conversion ====== | ====== Unit conversion ====== | ||

- | ACSUtils provides a range of functions to convert various commonly used units. **All** unit conversion function operate **only** on fixed-point numbers, even if ZDoom only uses integers for some of these units. | + | ACSUtils provides a range of functions to convert various commonly used units. All unit conversion functions operate only on fixed-point numbers, even if ZDoom only uses integers for some of these units. The only exception is byte angle conversion functions, because byte angles are always integers. |

Using the same units everywhere in your mod is a good practice that reduces potential for errors. ACSUtils uses the same units in all its functions. When calling ZDoom functions that don't use your preferred units, use these unit conversion functions to convert them in place. | Using the same units everywhere in your mod is a good practice that reduces potential for errors. ACSUtils uses the same units in all its functions. When calling ZDoom functions that don't use your preferred units, use these unit conversion functions to convert them in place. | ||

Line 10: | Line 10: | ||

* ZDoom fixed-point angles [0, 1] | * ZDoom fixed-point angles [0, 1] | ||

+ | * ZDoom byte angles [0 to 256, integers only] | ||

* Degrees [0, 360] | * Degrees [0, 360] | ||

* Radians [0, 6.28] | * Radians [0, 6.28] | ||

- | ZDoom fixed-point angles are the recommended angle unit in ZDoom, used by almost all actor functions, and used by all ACSUtils functions. | + | ZDoom fixed-point angles are the recommended angle unit in ZDoom, used by almost all ZDoom functions, and used by all ACSUtils functions. |

Angle units can be converted using the following functions (ang = ZDoom fixed-point angles, deg = Degrees, rad = Radians): | Angle units can be converted using the following functions (ang = ZDoom fixed-point angles, deg = Degrees, rad = Radians): | ||

Line 23: | Line 24: | ||

* ''fixed deg2rad(fixed degrees)'' -- converts degrees to radians | * ''fixed deg2rad(fixed degrees)'' -- converts degrees to radians | ||

* ''fixed rad2deg(fixed radians)'' -- converts radians to degrees | * ''fixed rad2deg(fixed radians)'' -- converts radians to degrees | ||

+ | * ''fixed byte2ang(int byteangle)'' -- converts ZDoom byte angle to fixed-point angle | ||

+ | * ''int ang2byte(fixed angle)'' -- converts fixed-point angle to ZDoom byte angle | ||

+ | |||

+ | ZDoom byte angles can also be converted to ZDoom fixed-point angles this way: | ||

+ | * ''x * 256'' -- byte angle to fixed-point angle (128 gets converted to 0.5) | ||

+ | * ''x / 256'' -- fixed-point angle to byte angle (0.5 gets converted to 128) | ||

+ | |||

+ | Or using bit shifts: | ||

+ | * ''x<<8'' -- byte angle to fixed-point angle | ||

+ | * ''x>>8'' -- fixed-point angle to byte angle | ||

===== Gravity units ===== | ===== Gravity units ===== |

new/units.txt ยท Last modified: 2018/02/17 14:06 by korshun