Re: A red point in plot3d

classic Classic list List threaded Threaded
4 messages Options
Lucio Agostinho Rocha Lucio Agostinho Rocha
Reply | Threaded
Open this post in threaded view
|

Re: A red point in plot3d

Hi,

To finish my work, I want to put some red points in this function:

   x=[-1:0.01:1];
   y=[-1:0.01:1];

   for i=1:length(x)
      for j=1:length(y)
         g(i,j) = x(i) .* sin((4*%pi) * x(i)) - y(j) .* sin ( (4*%pi) *  y(j) + %pi ) + 1;
      end
   end

Then, I tried to insert a new position in each list, like this:

   tx=length(x)+1;
   ty=length(y)+1;
   x(1,tx)=2;
   y(1,ty)=1;
   g(tx,ty)= x(tx) .* sin((4*%pi) * x(tx)) - y(ty) .* sin ( (4*%pi) *  y(ty) + %pi ) + 1;

   plot3d(x,y,g)

But this don't work. I've several values for x and y like '0.8987...' and '-0.321...'. How can I plot this points in my function? Some suggestion?

Thanks in advance,

Lucio
........


Veja quais são os assuntos do momento no Yahoo! + Buscados: Top 10 - Celebridades - Música - Esportes
harishankar ramachandran harishankar ramachandran
Reply | Threaded
Open this post in threaded view
|

Re: A red point in plot3d

I don't see any option to place a mark at (x,y,z) of a 3-D plot. There is
xpoly, but that works for 2-D plots. Others may be able to suggest something.

I suspect you need to go into plot3d and determine how (x,y,z) is mapped into
(x0,y0) on the graph. Once you know that, you can use any draw primitive and
place whatever you like at that point. One problem will be the handling of
hidden lines. Suppose your red point is not visible for the given theta,
alpha, should it still be drawn? How do we find out if it is hidden or not?

The first part of your code is not efficient. Better to code it as follows:

x=[-1:0.01:1]';
y=[-1:0.01:1];
g = (x .* sin(4*%pi*x))*ones(y) - ones(x)*(y .* sin(4*%pi*y+%pi)) + 1;
plot3d(x,y,g)

Avoid for loops whenever possible.

regards

hari ramachandran


On Sunday 17 May 2009 23:56, Lucio Agostinho Rocha wrote:

> Hi,
>
> To finish my work, I want to put some red points in this function:
>
>    x=[-1:0.01:1];
>    y=[-1:0.01:1];
>
>    for i=1:length(x)
>       for j=1:length(y)
>          g(i,j) = x(i) .* sin((4*%pi) * x(i)) - y(j) .* sin ( (4*%pi) * 
> y(j) + %pi ) + 1; end
>    end
>
> Then, I tried to insert a new position in each list, like this:
>
>    tx=length(x)+1;
>    ty=length(y)+1;
>    x(1,tx)=2;
>    y(1,ty)=1;
>    g(tx,ty)= x(tx) .* sin((4*%pi) * x(tx)) - y(ty) .* sin ( (4*%pi) * 
> y(ty) + %pi ) + 1;
>
>    plot3d(x,y,g)
>
> But this don't work. I've several values for x and y like '0.8987...' and
> '-0.321...'. How can I plot this points in my function? Some suggestion?
>
> Thanks in advance,
>
> Lucio
> ........
>
>
>       Veja quais são os assuntos do momento no Yahoo! +Buscados
> http://br.maisbuscados.yahoo.com

--
Dr. Hari Ramachandran, Professor, 332B ESB, EE Dept, IIT-Madras
Interests: Nonlinear Optics, Nonlinear Waves, Plasma Physics, Particle
           Simulations, Computational Algorithms, Linux.
Off: 91-44-2257-4421                    Fax: 91-44-2257-0120
Res: 91-44-2663-1863             Home Email: [hidden email]

Samuel GOUGEON-3 Samuel GOUGEON-3
Reply | Threaded
Open this post in threaded view
|

Re: A red point in plot3d

In reply to this post by Lucio Agostinho Rocha
----- Message d'origine -----
De : Lucio Agostinho Rocha
Date : 17/05/2009 20:26:
.../...
Then, I tried to insert a new position in each list, like this:

   tx=length(x)+1;
   ty=length(y)+1;
   x(1,tx)=2;
   y(1,ty)=1;
   g(tx,ty)= x(tx) .* sin((4*%pi) * x(tx)) - y(ty) .* sin ( (4*%pi) *  y(ty) + %pi ) + 1;

   plot3d(x,y,g)

But this don't work. I've several values for x and y like '0.8987...' and '-0.321...'. How can I plot this points in my function? Some suggestion?

Thanks in advance,

Lucio
........
Here is a trick that may work for this purpose:
After plot3d(), do a plot2d(Xp,Yp) where Xp and Yp are the 2 first coordinates of your
(Xp,Yp,Zp) set of points (Xp, Yp, Zp are vectors of same lengths N for N points to be marked)

Then, do:
ca=gca();
cc=ca.children(1).children(1);
cc.data(:,3)=Zp;  // Be carefull: Zp must be a column-vector
cc.line_mode='off';
cc.mark_mode='on';
cc.mark_style=8; // for diamonds. Run getmark() or see help polyline_properties for other marks
cc.mark_foreground=color('red');

This should yield what you are expecting

Regards
Samuel

Samuel GOUGEON-3 Samuel GOUGEON-3
Reply | Threaded
Open this post in threaded view
|

Re: A red point in plot3d

----- Message d'origine -----
De : Samuel GOUGEON
Date : 18/05/2009 14:51:
a trick that may work for this purpose:
After plot3d(), do a plot2d(Xp,Yp) where Xp and Yp are the 2 first coordinates of your
(Xp,Yp,Zp) set of points (Xp, Yp, Zp are vectors of same lengths N for N points to be marked)

Then, do:
ca=gca();
cc=ca.children(1).children(1);
cc.data(:,3)=Zp;  // Be carefull: Zp must be a column-vector
cc.line_mode='off';
cc.mark_mode='on';
cc.mark_style=8; // for diamonds. Run getmark() or see help polyline_properties for other marks
cc.mark_foreground=color('red');
See also
http://requestzilla.scilab.org/attachment.cgi?id=39 for an alpha release of a plotPoints() function,
where style, size and color of marks can be tuned.
http://requestzilla.scilab.org/show_bug.cgi?id=645  for discussion

SG