Plotting N-gons with multi-valued vertex color data

4 views (last 30 days)
I have had success in the past using patch() to plot triangle data with nodal colors -- where the color at the node can differ depending on which triangle is using the node at the time. Think of this as plotting the X component of a surface normal vector -- where the surface has a sharp corner. Triangles with sides along the ridge will share nodes on the ridge -- but the normal vector component depends on which triangle.
This can be achieved with:
patch(x,y,z,c);
Where x,y,z,c are all [3 x n] -- where 3 is for the nodes in the triangles, not RGB.
I have also had success using patch() to plot arbitrary n-gon's like this:
patch('Faces',con,'Vertices',p)
Where con is [npoly x maxnode]
Where maxnode is the maximum number of vertices for any polygon and con is padded with NAN for any un-used nodes.
And where p is [nvert x 3]
This ('Faces','Vertices') approach seems to work for face-valued colors (one color per face) and for vertex-valued colors (one color per vertex), but not for multi-valued vertex colors.
Is there a way to plot a mix of N-gons, but with multi-valued colors at the vertices?
My best idea is to build up the patch(x,y,z,c) approach with x,y,z,c all [maxnode x npoly], with repeated data to pad any lesser N-gons up to the maximum number of nodes.
Are there any other ways? Perhaps using the patch structure directly?
  3 Comments
Rob McDonald
Rob McDonald on 7 May 2023
Not sure what you mean -- do you suggest I color the wireframe? I would really prefer a solution that interpolates color across the faces.
Here is an example - generated with triangles.
This is a body intersected with a wing. Before being converted to triangles and intersected, the body and wing were parametric surfaces -- built on U,V coordinates. This is a plot of the V surface coordinate for every node.
V starts at 0 (blue) and goes to 1 (yellow). On the body, it starts on the top, goes counterclockwise (viewed from the front) and wraps around to the top again. On the wing, it starts at the bottom trailing edge (out of view), wraps around the leading edge (green) and back to the trailing edge. The sharp trailing edges are marked with a red and blue line.
The seam along the top of the body -- and the place where the body and wing join -- there are nodes that are coincident and are used to construct triangles. The V coordinate varies across each triangle.
Here is a pic of the underlying triangle mesh.
I am moving to a system where the mesh is made of polygons with an arbitrary number of nodes/edges -- but I would still like to create a plot like the blue to yellow one above. Here is a coarse example of the new mesh...
The mesh is mostly quads - with some tris around the nose and other degenerate points -- and also polygons with an arbitrary number of sides near intersections. For example, the panel on the body near the wing leading edge has nine sides.
Rob McDonald
Rob McDonald on 7 May 2023
I went ahead and tried the approach with patch(x,y,z,c) with all the data padded out with repeated vertices such that they all have the maximum number of verts observed in the set.
This works -- and unless someone has a better idea -- it will be good enough.

Sign in to comment.

Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!