[scilab-Users] 3d-project​ed-2d with colors as altitude

Samuel Gougeon sgougeon at free.fr
Thu Sep 22 22:29:58 CEST 2011


Le 22/09/2011 12:01, scibie a écrit :
> I have a 3d trajectory plot created using param3d1.
>
> I need to project the 3d trajectory plot to XY plane with color
> changes (from actual 3d trajectory TO xy-plane projected trajectory
> plot) according to altitude (z), like a colored waterfall.
>
> Kindly let me know how it could be done using Scilab.
>    
Yes it is possible as a series of adjacent but individual colored segments.
Hereabove is an example that you may adapt for your own purpose.

Best regards
Samuel

==========
// Preparing data:
theta = linspace(0,8*%pi,200);
r = 1 - 0.8*theta/(8*%pi);
x = r.*cos(theta);
y = r.*sin(theta);
z = 0.5+theta/10;

// Plotting the 3D parametric curve
clf
param3d1(x,y,z)

// Extending the z axis down to 0 in order to plot the (x,y) projection 
onto the z=0 plane:
a = gca();
a.data_bounds(1,3)=0;

// Preparing and updating the colormap:
ind = addcolor(rainbowcolormap(100));

// Mapping z with the generated rainbow colors:
zmin = min(z);
zmax = max(z);
zcol = ind(round(interp1([zmin zmax],[1 100],z)));

// Plotting the projection as a set of adjacent but individual colored 
segments:
X = [x(1:$-1);x(2:$)];
Y = [y(1:$-1);y(2:$)];
xpolys(X,Y,zcol(1:$-1))   // That's it

=======


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20110922/e89eaad0/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: moz-screenshot.png
Type: image/png
Size: 13376 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20110922/e89eaad0/attachment.png>


More information about the users mailing list