How can we save the color affected to a point and affect this color to another point (in 3D plot) ?

2 views (last 30 days)
Hello,
I am currently working with a list of points (3d coordinates). At the beginning, I have this list of coordinates (x list, y list, z list) in a local frame and when I plot it (with plot3k for instance) I have a color assigned to each point, depending on the z-value. Then, I rotate and translate these points and I plot them again, but I want to have the same color on each point than previously (it cannot be done with plot3k directly because the color depends on the new z-value).
I was thinking of saving the color assigned to each points in the local frame (so I will have a list of colors with the same length than the list of coordinates) and then assign again to each points its color after the rotation and translation. But I don't know how to do that exactly.
Could you help me ?
At the end, my functions will look like
function color_list = getColor(z_list_frame1)
%get the color code for each z-value
end
and
function my_plot3(x_list_frame2,y_list_frame2,z_list_frame2,color_list)
%plot each point with the corresponding color
end
Thank you in advance for your help !
  2 Comments
Image Analyst
Image Analyst on 14 Nov 2017
I don't understand your definition of "affected". The normal English definition of affected doesn't fit the context of your sentences. Just what does "affected" mean to you?

Sign in to comment.

Accepted Answer

N.
N. on 14 Nov 2017
Hello,
I found the solution I was looking for : with scatter3. I can directly do scatter3(x_list_frame2,y_list_frame2,z_list_frame2,2,z_list_frame1).
Thank you anyway.

More Answers (1)

KSSV
KSSV on 14 Nov 2017
Use delaunay triangulation....to plot what you want.
dt = delaunayTriangulation(x,y) ;
REad about triplot and trisurf.
  3 Comments
KSSV
KSSV on 15 Nov 2017
There are two ways to put a color......plot a mesh/ surface and put color or plot points and put color......for the first delaunay triangulation helps., for the second scatter helps.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!