Clear Filters
Clear Filters

How can I calculate the accuracy from a reference and test 3D model?

6 views (last 30 days)
Hello!
I have two 3D Meshes (STL format) that I need to compare to calculate the accuracy. First, the two meshes should be aligned. Afterwards, I need to determine the angular and distance difference (which represents the accuracy). I don't know how I can do this...

Answers (1)

Umang Pandey
Umang Pandey on 23 May 2024
Edited: Umang Pandey on 23 May 2024
Hi Iris,
To compare two 3D meshes in MATLAB and calculate their accuracy in terms of angular and distance differences, you can follow the following steps:
1) Read the STL Files:
You can use the "stlread" function from the following File Exchange Submission to obtain the faces and vertices from the mesh.
2) Align the Meshes (Registration):
For aligning the meshes, you could use the Iterative Closest Point (ICP) algorithm. You can use the “pcregistericp” function to register point clouds using ICP algorithm:
3) Calculate Angular and Distance Differences:
After alignment, you can calculate the distance differences between corresponding points. For a detailed analysis, you might need to establish a correspondence between points of the two meshes, which can be complex depending on the mesh structures.
A simple approach to calculate distance differences is to use the nearest neighbour distances after alignment:
% Find nearest neighbours
[idx, dists] = knnsearch(vertices2Aligned, vertices1);
% Calculate mean distance difference
meanDistDifference = mean(dists);
Calculating angular differences requires knowing the normals of corresponding points or faces and then computing the angle between these normals. Assuming you have normals (normals1 and normals2Aligned), you can calculate angular differences as follows:
% Assuming normals for each vertex or face are known
% You might need to compute or align normals if not already aligned
% Compute angular differences
dotProducts = dot(normals1, normals2Aligned(idx,:), 2);
angles = acosd(dotProducts);
% Calculate mean angular difference
meanAngularDifference = mean(angles);
Hope this helps!
Best,
Umang

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!