Finds plane of breechface marks using the RANSAC method

preProcess_ransacLevel(
x3p,
ransacInlierThresh = 1e-06,
ransacFinalSelectThresh = 2e-05,
iters = 300,
returnResiduals = TRUE
)

## Arguments

x3p an x3p object containing a surface matrix threshold to declare an observed value close to the fitted plane an "inlier". A smaller value will yield a more stable estimate. once the RANSAC plane is fitted based on the ransacInlierThresh, this argument dictates which observations are selected as the final breech face estimate. number of candidate planes to fit (higher value yields more stable breech face estimate) dictates whether the difference between the estimated breech face and fitted plane are returned (residuals) or if the estimates breech face is simply shifted down by its mean value

## Value

an x3p object containing the leveled surface matrix.

## Note

Given input depths (in microns), find best-fitting plane using RANSAC. This should be the plane that the breechface marks are on. Adapted from cartridges3D::findPlaneRansac function. This a modified version of the findPlaneRansac function available in the cartridges3D package on GitHub.

The preProcess_ransacLevel function will throw an error if the final plane estimate is rank-deficient (which is relatively unlikely, but theoretically possible). Re-run the function (possibly setting a different seed) if this occurs.

https://github.com/xhtai/cartridges3D

## Examples

if (FALSE) {