Translate 3D coordinates on a known surface

4 views (last 30 days)
Hi. I would like to know if there is a way to translate each 3D coordinate (blue dots) such that they lie on a known red surface.
Below is the code:
Nodes_XFix = load("Nodes_XFix.mat");
Nodes_XFix = Nodes_XFix.Nodes_XFix;
Faces_XFix = load("Faces_XFix.mat");
Faces_XFix = Faces_XFix.Faces_XFix;
coord_XMov = load("coord_XMov.mat");
coord_XMov = coord_XMov.coord_XMov;
figure
plot3(Nodes_XFix(:,1), Nodes_XFix(:,2), Nodes_XFix(:,3),'r.','Markersize',12)
hold on
trimesh(Faces_XFix(:,:),Nodes_XFix(:,1),Nodes_XFix(:,2),Nodes_XFix(:,3),'EdgeColor','r','Linewidth',1,'Facecolor','w')
plot3(coord_XMov(:,1), coord_XMov(:,2), coord_XMov(:,3),'b.','Markersize',12)
hold off
grid off
axis equal
xlabel('x')
ylabel('y')
zlabel('z')
view([15,50,30])
  7 Comments
Alberto Acri
Alberto Acri on 15 Jan 2023
Do all the blue points have to translate as a single rigid body, or do they all translate independently of each other?
Each blue dot must move independently of each other.
If the latter, which point on the red surface should a blue point move to? The closest point?
Yes, each blue dot must move across the red surface to the nearest point.
Matt J
Matt J on 15 Jan 2023
In future, please consolidate your variables into a single .mat file, as I have done here. This reduces the amount of work needed for us to download and import all your variables.

Sign in to comment.

Accepted Answer

Matt J
Matt J on 16 Jan 2023
  4 Comments
Alberto Acri
Alberto Acri on 17 Jan 2023
Yes it works!
I also tried with another dataset (closed surface) however it gives me the following "warning":
Warning: Some input points are not referenced by the triangulation.
Do you have any idea how to solve it?
Matt J
Matt J on 17 Jan 2023
I don't. Like I said, I've never used it before. It might help to see the complete warning message, though.

Sign in to comment.

More Answers (1)

Matt J
Matt J on 15 Jan 2023
[~,I]=pdist2( Nodes_XFix, coord_XMov,'euc','Smallest',1)
coord_XMov = Nodes_XFix(I,:);
  2 Comments
Alberto Acri
Alberto Acri on 16 Jan 2023
Thank you for your reply @Matt J! I observed that each blue point moves to the nearest red point.
Is there a possibility to move the blue points also on the surface of the triangles (red mesh) and not only on the vertices ? See, for example, the green dots in the figure below:
Matt J
Matt J on 16 Jan 2023
Edited: Matt J on 16 Jan 2023
It's going to be a lot more computation. Are you sure you need a rigorous projection? Obviously as the mesh gets finer, the difference diminishes.

Sign in to comment.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!