Learn R Programming

spatstat (version 1.23-1)

angles.psp: Orientation Angles of Line Segments

Description

Computes the orientation angle of each line segment in a line segment pattern.

Usage

angles.psp(x, directed=FALSE)

Arguments

x
A line segment pattern (object of class "psp").
directed
Logical flag. See details.

Value

  • Numeric vector.

Details

For each line segment, the angle of inclination to the $x$-axis (in radians) is computed, and the angles are returned as a numeric vector.

If directed=TRUE, the directed angle of orientation is computed. The angle respects the sense of direction from (x0,y0) to (x1,y1). The values returned are angles in the full range from $-\pi$ to $\pi$. The angle is computed as atan2(y1-y0,x1-x0). See atan2.

If directed=FALSE, the undirected angle of orientation is computed. Angles differing by $pi$ are regarded as equivalent. The values returned are angles in the range from $0$ to $\pi$. These angles are computed by first computing the directed angle, then adding $\pi$ to any negative angles.

See Also

summary.psp, midpoints.psp, lengths.psp

Examples

Run this code
a <- psp(runif(10), runif(10), runif(10), runif(10), window=owin())
  b <- angles.psp(a)

Run the code above in your browser using DataLab