# R/anglecheck.R In monogeneaGM: Geometric Morphometric Analysis of Monogenean Anchors

#### Documented in anglecheck

```#' Angle swept by a ray
#'
#' This function computes angle swept by a ray in anti-clockwise direction.
#' The ray starts at the half-line pointing towards the positive x direction,
#' and passes through the origin and a point defined by the user.
#' @param x a vector of length 2 giving the xy-coordinates of the point defined by the user
#' @author Tsung Fei Khang \email{tfkhang@@um.edu.my}
#' @references Khang TF, Soo OYM, Tan WB, Lim LHS. (2016). Monogenean anchor morphometry: systematic value, phylogenetic signal, and evolution. PeerJ 4:e1668.
#' @examples
#'

if(x == 0 & x == 0) return(0)

theta <- atan(abs(x)/abs(x))

theta2 <- (sign(x)==1)*(sign(x)==1)*theta +
(sign(x)==-1)*(sign(x)==1)*(pi-theta) +
(sign(x)==-1)*(sign(x)==-1)*(pi+theta) +
(sign(x)==1)*(sign(x)==-1)*(2*pi-theta) +
(x == 0) * sign(x > 0) * pi/2 +
(x == 0) * sign(x < 0) * 3*pi/2 +
(x > 0) * sign(x == 0) * 0 +
(x < 0) * sign(x == 0) * pi