Remove duplicated vertices - MATLAB Cody - MATLAB Central

Problem 45262. Remove duplicated vertices

Difficulty:Rate

First input V_in is a vertices list (X Y Z coordinates) which may contain duplicata (identical rows).

Second input T_in is the corresponding triangulation , in which each integer represents the row index of the vertex in the list V_in.

First output V_out -the easiest to compute- is the list of vertices without duplicata.

Second output T_out is a bit more tricky to compute : once you get rid of duplicated vertices, you of course have to update their corresponding indices in the triangulation array. The resulting table is T_out which admit no duplicated triangle.

NB : triangle orientations in T_out doesn't matter : [i1 i2 i3] is the same as [i3 i2 i1] for instance

Example on a regular octahedron included in the unit sphere :

V_in = [0 0 1;...
        sqrt(2) sqrt(2) 0;...
        -sqrt(2) sqrt(2) 0;...
        0 0 1;...        
        -sqrt(2) -sqrt(2) 0;...
        sqrt(2) sqrt(2) 0;...
        sqrt(2) -sqrt(2) 0;...
        0 0 -1];
T_in = [1, 2, 3;...
        1, 3, 5;...
        4, 5, 7;...
        2, 4, 7;...
        2, 3, 8;...
        3, 5, 8;...
        5, 7, 8;...
        2, 7, 8];
V_out = [0 0 1;...
         sqrt(2) sqrt(2) 0;...
         -sqrt(2) sqrt(2) 0;...           
         -sqrt(2) -sqrt(2) 0;...          
         sqrt(2) -sqrt(2) 0;...
         0 0 -1];
T_out = [1, 2, 3;... 
         1, 2, 5;...    
         1, 3, 4;...
         1, 4, 5;...                            
         2, 3, 6;...
         2, 5, 6;...
         3, 4, 6;...
         4, 5, 6];

That's all folks ! (for today at least)

Good work Matlab bro ! :)

Solution Stats

45.98% Correct | 54.02% Incorrect
Last Solution submitted on Jun 22, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
1
3

Problem Recent Solvers30

Suggested Problems

More from this Author18

Community Treasure Hunt

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

Start Hunting!