
Angle vector aware inverse trigonometric functions
Source:R/trigonometry.R
inverse-trigonometric-functions.Rdarcsine(), arccosine(), arctangent(),
arcsecant(), arccosecant(), and arccotangent() are
inverse trigonometric functions that return angle() vectors
with a user chosen angular unit.
Usage
arcsine(
x,
unit = getOption("affiner_angular_unit", "degrees"),
tolerance = sqrt(.Machine$double.eps)
)
arccosine(
x,
unit = getOption("affiner_angular_unit", "degrees"),
tolerance = sqrt(.Machine$double.eps)
)
arctangent(x, unit = getOption("affiner_angular_unit", "degrees"), y = NULL)
arcsecant(x, unit = getOption("affiner_angular_unit", "degrees"))
arccosecant(x, unit = getOption("affiner_angular_unit", "degrees"))
arccotangent(x, unit = getOption("affiner_angular_unit", "degrees"))Arguments
- x
A numeric vector
- unit
A string of the desired angular unit. Supports the following strings (note we ignore any punctuation and space characters as well as any trailing
s's e.g. "half turns" will be treated as equivalent to "halfturn"):"deg" or "degree"
"half-revolution", "half-turn", or "pi-radian"
"gon", "grad", "grade", or "gradian"
"rad" or "radian"
"rev", "revolution", "tr", or "turn"
- tolerance
If
xgreater than 1 (or less than -1) but is within atoleranceof 1 (or -1) then it will be treated as 1 (or -1)- y
A numeric vector or
NULL. IfNULL(default) we compute the 1-argument arctangent else we compute the 2-argument arctangent. For positive coordinates(x, y)thenarctangent(x = y/x) == arctangent(x = x, y = y).
Value
An angle() vector
Examples
arccosine(-1, "degrees")
#> <angle<degrees>[1]>
#> [1] 180°
arcsine(0, "turns")
#> <angle<turns>[1]>
#> [1] 0 tr
arctangent(0, "gradians")
#> <angle<gradians>[1]>
#> [1] 0 gon
arccosecant(-1, "degrees")
#> <angle<degrees>[1]>
#> [1] 180°
arcsecant(1, "degrees")
#> <angle<degrees>[1]>
#> [1] 90°
arccotangent(1, "half-turns")
#> <angle<pi-radians>[1]>
#> [1] 0.25π rad
# `base::atan2(y, x)` computes the angle of the vector from origin to (x, y)
as_angle(as_coord2d(x = 1, y = 1), "degrees")
#> <angle<degrees>[1]>
#> [1] 45°