Change face colors of tetrahedron mesh

조회 수: 4 (최근 30일)
Carlos
Carlos 2012년 4월 18일
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에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by