Cylinder#
- class Cylinder(centers, orientations, radius, height)[source]#
Bases:
ParametrizationParametrize a point cloud as a cylinder.
- Parameters:
- centersnp.ndarray
Center coordinates of the cylinder in X, Y, and Z.
- orientationsnp.ndarray
Orientation matrix (direction vectors).
- radiusfloat
Radius of the cylinder.
- heightfloat
Height of the cylinder.
Methods
Cylinder.compute_normal(points)Compute surface normals for points on the cylinder.
Cylinder.fit(positions, **kwargs)Fit a cylinder to a point cloud.
Cylinder.points_per_sampling(sampling_density)Computes the approximate number of random samples required to achieve a given spatial sampling_density.
Cylinder.sample(n_samples[, normal_offset, ...])Sample points from the surface of a cylinder.
- compute_normal(points)[source]#
Compute surface normals for points on the cylinder.
- Parameters:
- pointsnp.ndarray
Input points to compute normals for.
- Returns:
- normalsnp.ndarray
Computed surface normals.
- classmethod fit(positions, **kwargs)[source]#
Fit a cylinder to a point cloud.
Uses PCA for the initial axis estimate, then refines center, direction, and radius via constrained optimization (SLSQP).
- Parameters:
- positionsnp.ndarray
Point coordinates with shape (n, 3).
- Returns:
- Cylinder
Fitted cylinder with estimated center, orientation, radius, and height.
- points_per_sampling(sampling_density, normal_offset=None)[source]#
Computes the approximate number of random samples required to achieve a given spatial sampling_density.
- Parameters:
- sampling_densityfloat
Average distance between points.
- normal_offsetfloat, optional
Compute number of samples on offset parametrization, instead of current.
- Returns:
- int
Number of required random samples.
- sample(n_samples, normal_offset=0.0, mesh_init_factor=5, **kwargs)[source]#
Sample points from the surface of a cylinder.
- Parameters:
- n_samplesint
Number of samples to draw
- normal_offsetfloat, optional
Offset points by normal_offset times their normal vector.
- mesh_init_factorint, optional
Number of times the mesh should be initialized for Poisson sampling. Five appears to be a reasonable number. Higher values typically yield better sampling.
- Returns:
- np.ndarray
Point coordinates (n, 3).