solve2lines: Find solution of 2 intersecting lines

View source: R/solve2lines.R

solve2linesR Documentation

Find solution of 2 intersecting lines

Description

Find the intersection point of two lines.

Usage

solve2lines(line1, line2, toplot = TRUE)

Arguments

line1

A list containing two coordinate pairs defining the first line segment. Format: list(c(X1,Y1),c(X2,Y2)).

line2

A list containing two coordinate pairs defining the second line segment. Format: list(c(X3,Y3),c(X4,Y4)).

toplot

IfTRUE (the default), then a plot will be generated to show the lines and their intersection point. Plot range is defined by the end points of the lines.

Details

Developed for the function whalemap to test whether a bearing line from a vessel to a whale sighting intersects the shoreline before the horizon. In that scenario, line1 would be the bearing line between the vessel and the whale. line2 would be formed between two points in a shoreline polygon. This function would be looped to test for intersection between all shoreline points. It does not mess with Great-Sphere distances.

Value

A 2-element vector, the X and Y of the intersection point. If there is no solution (i.e., parallel lines), both elements are NA.

Author(s)

Eric Keen, Scripps Institution of Oceanography, ekeen@ucsd.edu

See Also

whalemap

Examples

line1 <- list(c(-129,53),c(-129.5,53.2))
line2 <- list(c(-128.5,53.12),c(-129.15,53.62))
solve2lines(line1,line2,toplot=TRUE)

ericmkeen/bangarang documentation built on Feb. 10, 2024, 2:58 p.m.