Learn R Programming

affiner (version 0.1.3)

inverse-trigonometric-functions: Angle vector aware inverse trigonometric functions

Description

arcsine(), 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"))

Value

An angle() vector

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 x greater than 1 (or less than -1) but is within a tolerance of 1 (or -1) then it will be treated as 1 (or -1)

y

A numeric vector or NULL. If NULL (default) we compute the 1-argument arctangent else we compute the 2-argument arctangent. For positive coordinates (x, y) then arctangent(x = y/x) == arctangent(x = x, y = y).

Examples

Run this code
arccosine(-1, "degrees")
arcsine(0, "turns")
arctangent(0, "gradians")
arccosecant(-1, "degrees")
arcsecant(1, "degrees")
arccotangent(1, "half-turns")

# `base::atan2(y, x)` computes the angle of the vector from origin to (x, y)
as_angle(as_coord2d(x = 1, y = 1), "degrees")

Run the code above in your browser using DataLab