pub fn icp_point_to_point(
source: &PointCloud<Point3f>,
target: &PointCloud<Point3f>,
init: Isometry3<f32>,
max_iterations: usize,
convergence_threshold: f32,
max_correspondence_distance: Option<f32>,
) -> Result<ICPResult>
Expand description
Point-to-point ICP registration
This function performs point-to-point ICP registration using Euclidean distance minimization. It finds the rigid transformation that best aligns the source point cloud to the target.
§Arguments
source
- Source point cloud to be alignedtarget
- Target point cloud to align toinit
- Initial transformation estimate (use Isometry3::identity() for no initial guess)max_iterations
- Maximum number of iterations to performconvergence_threshold
- MSE change threshold for convergence (default: 1e-6)max_correspondence_distance
- Maximum distance for valid correspondences (None = no limit)
§Returns
Result<ICPResult>
- Detailed ICP result including transformation, error, and convergence info
§Example
use threecrate_algorithms::icp_point_to_point;
use threecrate_core::{PointCloud, Point3f};
use nalgebra::Isometry3;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create source and target point clouds
let mut source = PointCloud::new();
let mut target = PointCloud::new();
// Add some points
for i in 0..10 {
let point = Point3f::new(i as f32, i as f32, 0.0);
source.push(point);
target.push(point + Point3f::new(1.0, 0.0, 0.0).coords); // Translated by (1,0,0)
}
let init = Isometry3::identity();
let result = icp_point_to_point(&source, &target, init, 50, 1e-6, None)?;
println!("Converged: {}, MSE: {}", result.converged, result.mse);
Ok(())
}