Trigonometric functions expecting input in degrees, not radians.

sind(x)
cosd(x)
tand(x)
cotd(x)
asind(x)
acosd(x)
atand(x)
acotd(x)
secd(x)
cscd(x)
asecd(x)
acscd(x)
atan2d(x1, x2)

Arguments

x, x1, x2

numeric or complex scalars or vectors

Details

The usual trigonometric functions with input values as scalar or vector in degrees. Note that tan(x) with fractional part does not return NaN as tanpi(x), but is computed as sind(x)/cosd(x).

For atan2d the inputs x1,x2 can be both degrees or radians, but don't mix! The result is in degrees, of course.

Value

Returns a scalar or vector of numeric values.

Note

These function names are available in Matlab, that is the reason they have been added to the `pracma' package.

See also

Other trigonometric functions in R.

Examples

# sind(x) and cosd(x) are accurate for x which are multiples
# of 90 and 180 degrees, while tand(x) is problematic.

x <- seq(0, 720, by = 90)
sind(x)                     # 0  1  0 -1  0  1  0 -1  0
#> [1]  0  1  0 -1  0  1  0 -1  0
cosd(x)                     # 1  0 -1  0  1  0 -1  0  1
#> [1]  1  0 -1  0  1  0 -1  0  1
tand(x)                     # 0  Inf  0  -Inf  0  Inf  0  -Inf  0
#> [1]    0  Inf    0 -Inf    0  Inf    0 -Inf    0
cotd(x)                     # Inf  0  -Inf  0  Inf  0  -Inf  0  Inf
#> [1]  Inf    0 -Inf    0  Inf    0 -Inf    0  Inf

x <- seq(5, 85, by = 20)
asind(sind(x))              # 5 25 45 65 85
#> [1]  5 25 45 65 85
asecd(sec(x))
#> [1]  73.521102   7.605512  58.310078 124.225668 169.858741
tand(x)                     # 0.08748866  0.46630766  1.00000000  ...
#> [1]  0.08748866  0.46630766  1.00000000  2.14450692 11.43005230
atan2d(1, 1)                # 45
#> [1] 45