cornelmpop / Lithics3D

An R package for processing and analyzing 3D scans of archaeological lithics
GNU General Public License v2.0
17 stars 3 forks source link

coords_onseg - incorrect output #14

Closed cornelmpop closed 11 months ago

cornelmpop commented 11 months ago

The following input should produce one TRUE value, but the output is FALSE, FALSE:

seg <- data.frame(x = c(-7.249440, -7.282816), y = c(0.5743027, 0.9284002), z = c(502.5920, 502.8661)) coords <- data.frame(x = c(-7.259582, -7.455739), y = c(0.6819025, 2.7629832), z = c(502.6753, 504.2863)) coords_onseg(coords, seg, tol = 0.01) # FALSE FALSE

dist_pt2l(coords, seg) # Not perfect, but clearly within a reasonable threshold of the line

Plot to visualize - one point is clearly on the segment:

lines3d(seg, col = "red") points3d(coords, col = "blue")

cornelmpop commented 11 months ago

There were two issues that were affecting unreleased code in version 0.5.1:

  1. No tolerance values were used when determining collinearity.
  2. The checks for whether the coordinate is within the line segment used the wrong variable.

Both issues have been fixed and a test has been added to prevent future recurrence.