Change face colors of tetrahedron mesh

1 次查看(过去 30 天)
I'm working with tetrahedrons and would like to change the color of them depending on their deformation. I have been trying but haven't found a solution.
I simplied it and tried this:
h=tetramesh(Tes,Graficos);
Color=get(h,'CData');
h=tetramesh(Tes,Graficos,'CData',Color);
What I wanted to do is just to get the color properties of the tetramesh and then assign it again, just to see if it works. I though is should work, since the form of the output COLOR should be "pure".
The output color is an structure array with the number of elements equal to the number of tetrahedron and in each cell there is an array 4x1. Each cell represents the color of each of the 4 faces of the tetrahedron.
This doesn't work and an error appeas:
??? Error using ==> patch
Value must be double or float
Error in ==> tetramesh at 100
h(n)=patch(x1,x2,x3,[1 1 1 1]*c(n),'FaceAlpha', 0.9,...
Could anyone help me with this problem? Why even taking the output of tetramesh, then it doesn't accept it?
Thanks a lot.
Carlos

采纳的回答

Sean de Wolski
Sean de Wolski 2012-4-18
what is:
class(x1)
class(x2)
class(x3)
class(c)
One of those will not be 'double' or 'single'. Convert that one to double using double().

更多回答(1 个)

Carlos
Carlos 2012-4-18
Thanks for the quick answer Sean.
What I expected was that since Color was the output it shouldn't generate any problem since the format should be right. The solution that I have found is to go tetrahedron by tetrahedron applying the function patch and there assign the {i} element of the structure array with the colors of the vertices. I have taken information such as vertices and faces for the patch function with function get from h=tetramesh.

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by