Segment operations

geos_segment_intersection(a, b)

geos_orientation_index(a, point)

Arguments

a, b

A list() representing segments in the form list(x0, y0, x1, y1). List items with length 1 will be recycled to the length of the longest item.

point

A list() representing points in the form list(x, y).

Value

geos_segment_intersection() returns a list(x, y); geos_orientation_index() returns -1, 0 or 1, depending if the point lies to the right of (-1), is colinear with (0) or lies to the left of (1) the segment (as judged from the start of the segment looking towards the end).

Examples

geos_segment_intersection(
  list(0, 0, 10, 10),
  list(10, 0, 0, 10)
)
#> $x
#> [1] 5
#> 
#> $y
#> [1] 5
#> 

geos_orientation_index(
  list(0, 0, 10, 10),
  list(15, c(12, 15, 17))
)
#> [1] -1  0  1