perpproj: Perpendicular Projection

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Perpendicular Projection in two-dimensions

Usage

1
2
perpproj(V1, V2, add = FALSE)
pointproj(P1, VEC )

Arguments

V1

vector 1

V2

vector 1

add

logical, TRUE add to plot

P1

point coordinates,

VEC

vector coordinates,

Details

V1 and V2 are arrays with, for example, V1=c(x1 , x2 , y1, y2) or lists with V2=list(x=c(x1, x2), y-c(y1, y2)) which gets converted into the first format.

The points are from the head of each vector projected onto the the line formed by the other vector. If the the x1 y1 of each vector do not coincide, the interesections of two lines is determined and the tail of each vector is moved to that point for determining the projection positions.

for the pointproj the input can be a 2-element vector or a list with (x,y) elements. The VEC should be organized, as (x1,x2, y1, y2) or as an (x,y) list. The P1 vector can include many points, so a large number of projections are doable.

Value

list:

P1

x, y

P2

x, y

Author(s)

Jonathan M. Lees<jonathan.lees@unc.edu>

See Also

vecproj

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  V1 = c( 2,  6, 1, 9)
    V2 = c( 0, 5,  1, 2)

  
    PP = perpproj( V1, V2, add=FALSE  )


    R = range(c(V1, V2, unlist(PP) ))

    plot(R, R, type='n', asp=1)

    arrows(V1[1], V1[3], V1[2], V1[4], length=.08 ) 
   arrows(V2[1], V2[3], V2[2], V2[4], length=.08 ) 

    points(PP$P1[1],PP$P1[2], col='red')
       points(PP$P2[1],PP$P2[2], col='blue')



    arrows(V2[2], V2[4],PP$P1[1],PP$P1[2] , length=.08, col='red' )
    
    arrows(V1[2], V1[4], PP$P2[1],PP$P2[2], length=.08, col='blue' ) 
 

geophys documentation built on May 1, 2019, 9:26 p.m.