Problem statement
An pentagon is a regular polygon with 5 vertices and 5 edges. Here below is an example of the vertex set V, corresponding to the XYZ coordinates column vectors of a pentagon included in the unit circle.
V = [1 0 0;
cos(2*pi/5) sin(2*pi/5) 0;
cos(4*pi/5) sin(4*pi/5) 0;
cos(4*pi/5) sin(-4*pi/5) 0;
cos(2*pi/5) sin(-2*pi/5) 0];
A triangulated mesh T (stands for triangles here) -or a triangulation- is simply a N x 3 matrix of positive integers where each row contains the vertex indices of a triangle, and where N is the number of triangles.
Your task here is to mesh this pentagon with the minimum possible number of triangles. To do so, you will list the pentagons/rows in a matrix of faces, F. The row order of the triangles in the list doesn't matter.
Example
The first triangle here can be [1, 2, 3] if counterclockwise oriented.
Tip
Beware to avoid self intersecting triangles.
Forbidden functions / expressions
- regexp
- assignin
- str2num
- echo
See also
Solution Stats
Problem Comments
4 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers29
Suggested Problems
More from this Author42
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
To visualize and check your result you can do for instance :
trisurf(T,V(:,1),V(:,2),V(:,3));
colormap([0 1 1]);
axis equal, alpha(0.5);
Hi, I was wondering should the following mesh pass the test:
T = [1, 2, 3; 5, 1, 3; 4, 5, 3]
There should not be intersecting triangles, and the triangle vertices should be enumerated counter-clockwise.
Hi Pauli. You are right of course. Actually it corresponds to the test case #4,
T_correct4 = [3 4 5; 3 5 1; 3 1 2];
but while improving the tests, I forgot to put back the circular shift possibilities. I am going to do it now. Thanks again.
There was a little bug in the tests. I just fixed them. Thanks again for this feedback Pauli.