coords_onseg: Determine if coordinates are on a line segment

View source: R/geom_dist.R

coords_onsegR Documentation

Determine if coordinates are on a line segment

Description

[Stable]

Usage

coords_onseg(coords, seg, tol = 0)

Arguments

coords

A Nx3 matrix-like object with x, y, and z point coordinates, one per row.

seg

A 2x3 matrix-like object containing x, y, and z coordinates for two points that define the line segment.

tol

(optional) Tolerance value for distance from the line segment; useful to deal with floating point precision errors. Default is 0.

Details

Determines if the given input coordinates lie on a line segment or not.

Value

A Boolean vector indicating, for each input coordinate, whether they lie on the given line segment

Author(s)

Cornel M. Pop

See Also

proj_pt2l() for projecting coordinates orthogonally onto a line.

Examples

coords = data.frame(x = c(14.830469, 12.812613),
                    y = c(-84.840050, -79.966871),
                    z = c(2.938235, 2.302472))
seg = data.frame(x = c(12.84073, 12.49499), y = c(-80.03477, -79.19981),
                 z = c(2.311330, 2.202399))
coords_onseg(coords, seg) # False, False
coords_onseg(coords, seg, tol = 0.001) # False, True

## Not run: 
library(rgl)
points3d(coords, color = "red")
lines3d(seg), color = "blue")

## End(Not run)


cornelmpop/Lithics3D documentation built on Feb. 10, 2024, 11:54 p.m.