cylinderFit: Point cloud cylinder fitting as per de Conto et al. 2017 as...

View source: R/utils.R

cylinderFitR Documentation

Point cloud cylinder fitting as per de Conto et al. 2017 as implemented here: https://github.com/tiagodc/TreeLS

Description

Fits a cylinder on a set of 3D points.

Usage

cylinderFit(
  las,
  method = "ransac",
  n = 5,
  inliers = 0.9,
  conf = 0.95,
  max_angle = 30,
  n_best = 20
)

Arguments

las

LAS normalized and segmented las object.

method

method for estimating the cylinder parameters. Currently available: "nm", "irls", "ransac" and "bf".

n

number of points selected on every RANSAC iteration.

inliers

expected proportion of inliers among stem segments' point cloud chunks.

conf

confidence level.

max_angle

used when method == "bf". The maximum tolerated deviation, in degrees, from an absolute vertical line (Z = c(0,0,1)).

n_best

estimate optimal RANSAC parameters as the median of the n_best estimations with lowest error.

Value

vector of parameters

Examples

# Define the cylinder attributes
npts = 500
cyl_length = 0.5
radius = 0.2718

# Generate the X,Y,Z values
Z=runif(n = n, min = 0, max = cyl_length)
angs = runif(n, 0, 2*pi)
X = sin(angs)*radius
Y = cos(angs)*radius

# Creation of a LAS object out of external data
cloud <- LAS(data.frame(X,Y,Z))

# Fit a cylinder and retrun the information
cyl_par = spanner::cylinderFit(cloud, method = 'ransac', n=5, inliers=.9,
                               conf=.95, max_angle=30, n_best=20)

bi0m3trics/spanner documentation built on June 9, 2025, 3:57 p.m.