Angle units and conversions.
More...
|
function | a_deg (a) |
| Shorthand angle conversion for degrees. More...
|
|
function | a_rad (a) |
| Shorthand angle conversion for radians. More...
|
|
Angle units and conversions.
These functions allow for angles to be specified with units. Angles specified with units are independent of (angle_unit_base). There are also unit conversion functions for converting from one unit to another.
The table below enumerates the supported units.
units id | description | type |
r | radian | decimal |
d | degree | decimal |
dms | degree, minute, second | decimal-list-3 |
Angle base unit example script
include <omdl-base.scad>;
c4 =
angle([30, 15, 50],
"dms");
c5 =
angle([30, 15, 50], from=
"dms", to=
"r");
c6 =
angle(0.528205, to=
"dms");
pi
<decimal> The ratio of a circle's circumference to its diameter.
function angle(a, from=angle_unit_default, to=angle_unit_base)
Convert an angle from some units to another.
angle_unit_default
<string> The default units when unspecified.
function angle_unit_name(u=angle_unit_default)
Return the name of an angle unit identifier.
angle_unit_base
<string> The base units for value storage.
angle_unit_base=r script output
ECHO: bu = "radian"
ECHO: du = "radian"
ECHO:
ECHO: c1 = 0.523599
ECHO: c2 = 0.785398
ECHO: c3 = 3.14159
ECHO: c4 = 0.528205
ECHO: c5 = 0.528205
ECHO: c6 = [30, 15, 50.102]
angle_unit_base=d script output
ECHO: bu = "degree"
ECHO: du = "radian"
ECHO:
ECHO: c1 = 30
ECHO: c2 = 45
ECHO: c3 = 180
ECHO: c4 = 30.2639
ECHO: c5 = 0.528205
ECHO: c6 = [30, 15, 50.102]
angle_unit_base=dms script output
ECHO: bu = "degree, minute, second"
ECHO: du = "radian"
ECHO:
ECHO: c1 = [29, 59, 60]
ECHO: c2 = [45, 0, 0]
ECHO: c3 = [180, 0, 0]
ECHO: c4 = [30, 15, 50]
ECHO: c5 = 0.528205
ECHO: c6 = [30, 15, 50.102]
◆ a_deg()
Shorthand angle conversion for degrees.
- Parameters
-
a | <decimal> The angle to convert. |
- Returns
- <decimal> The conversion result.
◆ a_rad()
Shorthand angle conversion for radians.
- Parameters
-
a | <decimal> The angle to convert. |
- Returns
- <decimal> The conversion result.
◆ angle()
Convert an angle from some units to another.
- Parameters
-
a | <decimal | decimal-list-3> An angle to convert. |
from | <string> The units of the angle to be converted. |
to | <string> A units to which the angle should be converted. |
- Returns
- <decimal | decimal-list-3> The conversion result. Returns undef for identifiers that are not defined.
◆ angle_inv()
Convert an angle from some units to another.
- Parameters
-
a | <decimal | decimal-list-3> An angle to convert. |
from | <string> The units of the angle to be converted. |
to | <string> A units to which the angle should be converted. |
- Returns
- <decimal | decimal-list-3> The conversion result. Returns undef for identifiers that are not defined.
◆ angle_unit_name()
Return the name of an angle unit identifier.
- Parameters
-
u | <string> An angle unit identifier. |
- Returns
- <string> The units name for the given angle unit identifier. Returns undef for identifiers that are not defined.