MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: from Graphics3D to 2D

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21333] Re: from Graphics3D to 2D
  • From: Maarten.vanderBurgt at icos.be
  • Date: Sun, 26 Dec 1999 01:26:11 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Allan, Bob, Pascal, David, Russell,


Thank you all very much for you help.
In the example I gave the idea was manipulating the Graphics3D object, not
the list of 3D points. This way you can project more complicated graphics
contianing lines, point, polygons, cuboids,... Manipulating the underlying
lists could get tedious.
In that sense I preferred Alan's solution.
In a lot of cased it can even be done more simple. Instead of
Point[{x_,y_,z_}]->Point[{y,z}] you can use {x_,y_,z_}->{y,z}.
Have a look at the example below: a SurfaceGraphics object is converted to
a Graphics3D object,which in turn is projected onto three planes. Without
the WireFrame the projections would be all black. I had to replace Cuboid
by Rectangle as well to make it work. There might be more such snags with
more complicated examples. But is has done the job for me (projecting some
ray traces with extra graphics from the Optica package).


Thanks a lot

Have a merry Christmas and a happy 2000.

Maarten


In[1]:= << Graphics`Shapes`

In[2]:= lp = ListPlot3D[Table[Sin[x*y] + Random[Real, {-0.15, 0.15}], {x,
0, (3*Pi)/2, Pi/5},{y, 0, (3*Pi)/2, Pi/5}]]

- SurfaceGraphics - not shown -

In[3]:= lp2 = Show[WireFrame /@ {Graphics3D[ lp],Graphics3D[Cuboid[{4.1,
4.1, 0.1}, {4.5, 4.5, 3}]]}]

- Graphics3D - not shown -

In[4]:=
Show[Graphics[lp2[[1]] /. {x_, y_, z_} -> {x, y} /. Cuboid -> Rectangle]] ;
Show[Graphics[lp2[[1]] /. {x_, y_, z_} -> {y, z} /. Cuboid -> Rectangle]] ;
Show[Graphics[lp2[[1]] /. {x_, y_, z_} -> {x, z} /. Cuboid -> Rectangle]] ;

- Graphics - not shown






"Allan Hayes" <hay at haystack.demon.co.uk> on 22-12-99 08:18:42 AM

cc:

Subject: [mg21333]  Re: from Graphics3D to 2D




Maarten,

Taking your example

<<Graphics`Graphics3D`

lpts = Table[{ t Cos[t], t Sin[t], t}, {t, 0, 4Pi, Pi/20}];
spir = ScatterPlot3D[lpts]
gr3d=Show[Project[spir, {{0, 0, 1}, {0, 1, 0}}, {0, 0, 0}], ViewPoint
-> {10^200, 0, 0}]

We can convert
gr2d=Show[Graphics[gr3d], Frame->True]

But the ticks are incorrect.

In this case we can get the correct ticks by

Show[Graphics[gr3d[[1]]/.Point[{x_,y_,z_}]->Point[{y,z}]],
Frame->True]

More generally, see Tom Wickham Jones, Mathematica Graphics, p436.
This has a function, ParallelProjectTo2D in the package
ExtendGraphics`Geometry` , available in collection ExtendGraphics from
MathSource.

Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

<Maarten.vanderBurgt at icos.be> wrote in message
news:83pnal$800 at smc.vnet.net...
>
> Hallo,
>
> in the Mathematica lines below I am doing the following:
> - lpts is a list of (x,y,z) coordinates
> - these points are plotted usign ScatterPlot3D, which returns a
Graphics3D
> object.
> - Using Project I project the Graphics3D object onto the y-z plane
> - Project also returns a Graphics3D object
> - I use ViewPoint -> {10^200, 0, 0} to make it look like a 2D graphics
> object
>
> My question: is there a way to convert the Graphics3D object into a real
2D
> Graphics object?
>
> <<Graphics`Graphics3D`
>
> In[14]:= lpts = Table[{ t Cos[t],  t Sin[t], t}, {t, 0, 4Pi, Pi/20}];
>
> In[15]:= spir = ScatterPlot3D[lpts]
> - graphics not shown -
> Out[15]= -Graphics3D-
>
> In[16]:= Show[Project[spir, {{0, 0, 1}, {0, 1, 0}}, {0, 0, 0}], ViewPoint
> -> {10^200, 0, 0}]
> - graphics not shown -
> Out[16]= -Graphics3D-
>
>
> thanks for your help
>
> Maarten van der Burgt
> Leuven
>
>
>
>







  • Prev by Date: Re: Eigensystem applied to a unitary matrix crashes Mathematica 4.
  • Next by Date: Re: Circuit Analyses with Mathematica
  • Previous by thread: from Graphics3D to 2D
  • Next by thread: emmathfnt for Mathematica 3