Re: animation of coloured points on a surface graphics?
- To: mathgroup@smc.vnet.net
- Subject: [mg11679] Re: animation of coloured points on a surface graphics?
- From: Allan Hayes <hay@haystack.demon.co.uk>
- Date: Sat, 21 Mar 1998 18:35:15 -0500
- References: <6esn5k$64m@smc.vnet.net>
Heiko Appel wrote: > > I tried to plot coloured points on a surface graphics. My first attempt > looked like this: > > --------------------------------------------------------------------------- > <<Graphics`Graphics3D` (* for ScatterPlot3D *) > > (* Definition of a function *) > f[x_,y_]:= -x Sin[Sqrt[Abs[x]]] -y Sin[Sqrt[Abs[y]]] > > (* Plot of this function *) > p1:=Plot3D[f[x,y],{x,-500,500},{y,-500,500},PlotPoints->50] > > (* 100 random points on this surface *) > mypoints:=Table[{a=Random[Real,500],b=Random[Real,500],f[a,b]},{x,0,100}] > > (* plot of the points *) > p2:=ScatterPlot3D[mypoints] > > (* plot of points and surface *) > plot:=Show[p1,p2] > > --------------------------------------------------------------------------- > > But now I don't know how to give mypoints a color (e.g. red) or how to > show them in a bigger fashion????? > In the next step I want to animate different sets of points on the > surface p1; e.g in this way: > > for i=1 to 100 do > .. > mypoints_new = move[mypoints] (* here is move a self defined > function > which changes the coordinates of > the > points slightly *) > p2:=ScatterPlot3D[mypoints_new] > .. > Show[p1,p2] > > > This gives in every step a plot of the changed points but also the > surface (which has not changed!) is drawn again. And it's no real > animation, only a sequence of pictures! > Is there a way to program an animation in only one X-Window and how can > I accelerate the calculation????? > > Heiko :-) Heiko, Some suggestions for the first part. (*make graphics obect for surface - don't show it (DisplayFunction -> Identity) Note =, not :=. The surface is computed here - not every time that pl is used *) p1=Plot3D[f[x,y],{x,-500,500},{y,-500,500},PlotPoints->50, DisplayFunction -> Identity]; (* 100 random points on this surface Note: use of pure function; I've left := so that new points are generated each time mypoints is used - you could store one version for comparison *) mypoints:=Table[ Point[{#1,#2, f[#1,#2]}]&[Random[Real,500],Random[Real,500]],{100}]; (* make points into Graphics3D object with specified color and size. Using ScatterPlot3d the size and color can be specified by the option PlotStyle ->{Hue[0],PointSize[0.02]}*) p2 = Graphics3D[{Hue[0],PointSize[0.02],mypoints}]; (* plot points and surface - turn display back on (DisplayFunction -> $DisplayFunction) *) plot=Show[p1,p2, DisplayFunction -> $DisplayFunction] -- Allan Hayes Training and Consulting Leicester, UK hay@haystack.demon.co.uk http://www.haystack.demon.co.uk voice: +44 (0)116 271 4198 fax: +44 (0)116 271 8642