Learn R Programming

pgirmess (version 2.0.2)

dirSeg: Computes segment directions.

Description

Computes the direction of segments from the first top clockwise (North = 0)

Usage

dirSeg(x,deg=TRUE)

Value

A vector of directions

Arguments

x

a matrix or data frame of 4 columns giving the coordinates of each segment tops x1, y1, x2, y2

deg

if TRUE (default) the output is in degrees, otherwise in radians

Details

The first two colomns give the first top coordinates, x then y, and the next two the second top coordinates.

See Also

dirProj, gzAzimuth

Examples

Run this code

x2<-rnorm(10)
y2<-rnorm(10)
mydata<-cbind(0,0,x2,y2)
dirs<-dirSeg(mydata)
dirs

plot(range(mydata[,c(1,3)]),range(mydata[,c(2,4)]),type="n")
Segments(mydata)
text(mydata[,3],mydata[,4],paste(round(dirs,0),"\u00b0"),cex=0.7)
  

Run the code above in your browser using DataLab