MathGroup Archive 1995

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

Search the Archive

Re: How to apply EdgeForm to ParametricPlot3D?

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg1724] Re: How to apply EdgeForm to ParametricPlot3D?
  • From: deppeler at math.ethz.ch (Harry Deppeler)
  • Date: Thu, 20 Jul 1995 23:46:37 -0400
  • Organization: Swiss Federal Institute of Technology (ETHZ)

Dave Wagner (wagner at bullwinkle.cs.Colorado.EDU) wrote:
: In article <DBKyKB.4BF at wri.com>,
: Gabriel Berriz  <berriz at husc.harvard.edu> wrote:
: >
: >
: >Hello.  Is it possible to apply the EdgeForm Graphics3D directive to a
: >surface plot done with ParametricPlot3D?  The Book says nothing to the
: >contrary, but I haven't found a way of getting it to work
: >(i.e. ParametricPlot3D *always* draws black edges on the polygons
: >forming the surface, regardless of EdgeForm directives).  Does anybody
: >know how to do it?

: You can apply EdgeForm to *any* Graphics3D object.  The form of a
: Graphics3D object is "Graphics3D[primitives, options]", where each
: of the two parts is a list. (A list of polygons, lines, and so forth
: in the first case, and a list of options in the second.)  Hence the
: following does what you want with the Graphics3D object "g3dobj":

: Show[Graphics3D[{EdgeForm[whatever], g3dobj[[1]]}, g3dobj[[2]] ]]

: where "whatever" is a list of style directives.  Note that the primitives
: (the first element of the object) can be arbitrarily nested, so there's
: no problem adding another level of nesting to it.  You can leave out
: the second componenet if you want to, but then you would lose any special
: formatting options that were already in the object.

: Here's an example.  I have no idea what this gizmo is but it was the
: first thing I could think of plotting parametrically.

: In[1]:=
: ParametricPlot3D[{Sin[u], Cos[u]Sin[t], Cos[t]}, {u,-Pi,0}, {t,0,Pi}]

: In[2]:=
: Show[Graphics3D[{EdgeForm[Hue[0]], %[[1]]}, %[[2]]]]

: 		Dave Wagner
: 		Principia Consulting
: 		(303) 786-8371
: 		dbwagner at princon.com
: 		http://www.princon.com/princon


Hi!

A while ago I run into the same problem. I did not manage to get this
to work the way I wanted to (and I used the recipe above as well) ---
I hope, this was a bug of the version I used then. I've no time to
reproduce the results now or to check whether they're gone, but back
then I just hacked the package (which looks different in the current
versions I understand):

I changed 

ParametricPlot3D[ fun_,
                  ul:{_, u0_, u1_, du_},
                  vl:{_, v0_, v1_, dv_},
                  opts___] :=
        Show[Graphics3D[ MakePolygons[Table[N[fun], ul, vl]] ],
opts] /;
                        NumberQ[N[u0]] && NumberQ[N[u1]] && NumberQ[N[du]] &&
                        NumberQ[N[v0]] && NumberQ[N[v1]] && NumberQ[N[dv]]

into 

ParametricPlot3D[ fun_,
                  ul:{_, u0_, u1_, du_},
                  vl:{_, v0_, v1_, dv_},
                  opts___] :=
        Show[Graphics3D[ {EdgeForm[ ], MakePolygons[Table[N[fun], ul, vl]] } ],
                         ^^^^^^^^^^^^^                                    ^^^
Opts] /;
                        NumberQ[N[u0]] && NumberQ[N[u1]] && NumberQ[N[du]] &&
                        NumberQ[N[v0]] && NumberQ[N[v1]] && NumberQ[N[dv]]

I hope this helps if nothing else helps.
In case you don't have the old package, I will include it here.
Just read it in instead of using the ParametricPlot3D included with
your version of mathematica and everything will be fine.

cu 
harald (deppeler at math.ethz.ch)



(* Copyright 1988 Wolfram Research Inc. *)

(* One and Two Parameter 3D Plots *)

(* by Roman Maeder *)

BeginPackage["Graphics`ParametricPlot3D`"]

ParametricPlot3D::usage =
     "ParametricPlot3D[{x,y,z}, {u,u0,u1,(du)}, {v,v0,v1,(dv)}, (options..)]
	plots a 3D parametric surface. Options are passed to Show[]"

PointParametricPlot3D::usage =
  "PointParametricPlot3D[{x,y,z}, {u,u0,u1,(du)}, {v,v0,v1,(dv)}, (options..)]
	plots a two-parameter set of points in space.
	Options are passed to Show[]"

SpaceCurve::usage =
     "SpaceCurve[{x,y,z}, {u,u0,u1,(du)}, (options..)]
	plots a 3D parametric curve. Options are passed to Show[]"

PointSpaceCurve::usage =
     "PointSpaceCurve[{x,y,z}, {u,u0,u1,(du)}, (options..)]
	plots a one-parameter set of points in space.
	Options are passed to Show[]"

SphericalPlot3D::usage = "SphericalPlot3D[r, {theta-range}, {phi-range},
	(options...)] plots r as a function of the angles theta and phi."


Begin["`Private`"]

MakePolygons[vl_List] :=
    Block[{l = vl,
    	   l1 = Map[RotateLeft, vl],
    	   mesh},
	mesh = {l, l1, RotateLeft[l1], RotateLeft[l]};
	mesh = Map[Drop[#, -1]&, mesh, {1}];
	mesh = Map[Drop[#, -1]&, mesh, {2}];
	Polygon /@ Transpose[ Map[Flatten[#, 1]&, mesh] ]
    ]


Attributes[ParametricPlot3D] = {HoldFirst}

ParametricPlot3D[ fun_,
		  ul:{_, u0_, u1_, du_},
		  vl:{_, v0_, v1_, dv_},
		  opts___] :=
	Show[Graphics3D[ {EdgeForm[ ], MakePolygons[Table[N[fun], ul, vl]] } ], opts] /;
			NumberQ[N[u0]] && NumberQ[N[u1]] && NumberQ[N[du]] &&
    			NumberQ[N[v0]] && NumberQ[N[v1]] && NumberQ[N[dv]]

ParametricPlot3D[fun_, {u_, u0_, u1_}, {v_, v0_, v1_}, opts___] :=
    Block[{plotpoints},
    	plotpoints = PlotPoints /. {opts} /. Options[Plot3D];
	ParametricPlot3D[ fun,
			  {u, u0, u1, (u1-u0)/(plotpoints-1)},
			  {v, v0, v1, (v1-v0)/(plotpoints-1)},
			  opts ]
    ]

ParametricPlot3D[fun_, ulim:{_, _, _, _}, {v_, v0_, v1_}, opts___] :=
    Block[{plotpoints},
    	plotpoints = PlotPoints /. {opts} /. Options[Plot3D];
	ParametricPlot3D[ fun,
			  ulim,
			  {v, v0, v1, (v1-v0)/(plotpoints-1)},
			  opts ]
    ]

ParametricPlot3D[fun_, {u_, u0_, u1_}, vlim:{_, _, _, _}, opts___] :=
    Block[{plotpoints},
    	plotpoints = PlotPoints /. {opts} /. Options[Plot3D];
	ParametricPlot3D[ fun,
			  {u, u0, u1, (u1-u0)/(plotpoints-1)},
			  vlim,
			  opts ]
    ]


Attributes[PointParametricPlot3D] = {HoldFirst}

PointParametricPlot3D[ fun:{_, _, _},
		  ul:{_, u0_, u1_, du_},
		  vl:{_, v0_, v1_, dv_},
		  opts___] :=
	Show[ Graphics3D[Table[Point[N[fun]], ul, vl]], opts ] /;
			NumberQ[N[u0]] && NumberQ[N[u1]] && NumberQ[N[du]] &&
    			NumberQ[N[v0]] && NumberQ[N[v1]] && NumberQ[N[dv]]

PointParametricPlot3D[fun_, {u_, u0_, u1_}, {v_, v0_, v1_}, opts___] :=
    Block[{plotpoints},
    	plotpoints = PlotPoints /. {opts} /. Options[Plot3D];
	PointParametricPlot3D[ fun,
		     {u, u0, u1, (u1-u0)/(plotpoints-1)},
		     {v, v0, v1, (v1-v0)/(plotpoints-1)},
		     opts ]
    ]

PointParametricPlot3D[fun_, ulim:{_, _, _, _}, {v_, v0_, v1_}, opts___] :=
    Block[{plotpoints},
    	plotpoints = PlotPoints /. {opts} /. Options[Plot3D];
	PointParametricPlot3D[ fun,
		     ulim,
		     {v, v0, v1, (v1-v0)/(plotpoints-1)},
		     opts ]
    ]

PointParametricPlot3D[fun_, {u_, u0_, u1_}, vlim:{_, _, _, _}, opts___] :=
    Block[{plotpoints},
    	plotpoints = PlotPoints /. {opts} /. Options[Plot3D];
	PointParametricPlot3D[ fun,
		     {u, u0, u1, (u1-u0)/(plotpoints-1)},
		     vlim,
		     opts ]
    ]


Attributes[SpaceCurve] = {HoldFirst}

SpaceCurve[ fun:{_, _, _}, ul:{_, u0_, u1_, du_}, opts___] :=
	Show[ Graphics3D[Line[Table[N[fun], ul]]], opts ] /;
			NumberQ[N[u0]] && NumberQ[N[u1]] && NumberQ[N[du]]

SpaceCurve[fun_, {u_, u0_, u1_}, opts___] :=
    Block[{plotpoints},
    	plotpoints = PlotPoints /. {opts} /. Options[Plot3D];
	SpaceCurve[ fun, {u, u0, u1, (u1-u0)/(plotpoints-1)}, opts ]
    ]


Attributes[PointSpaceCurve] = {HoldFirst}

PointSpaceCurve[ fun:{_, _, _}, ul:{_, u0_, u1_, du_}, opts___] :=
	Show[ Graphics3D[Table[Point[N[fun]], ul]], opts ] /;
			NumberQ[N[u0]] && NumberQ[N[u1]] && NumberQ[N[du]]

PointSpaceCurve[fun_, {u_, u0_, u1_}, opts___] :=
    Block[{plotpoints},
    	plotpoints = PlotPoints /. {opts} /. Options[Plot3D];
	PointSpaceCurve[ fun, {u, u0, u1, (u1-u0)/(plotpoints-1)}, opts ]
    ]


Attributes[SphericalPlot3D] = {HoldFirst}

SphericalPlot3D[ r_, tlist:{theta_, __}, plist:{phi_, __}, opts___ ] :=
    Block[{rs},
      ParametricPlot3D[{(rs = r) Sin[theta] Cos[phi],
    			rs Sin[theta] Sin[phi],
    			rs Cos[theta]},
    		       tlist, plist, opts]
    ]

End[]

Protect[ParametricPlot3D, PointParametricPlot3D, SpaceCurve,
	PointSpaceCurve, SphericalPlot3D]

EndPackage[]

Null


  • Prev by Date: Re: Q) How to clear all variables
  • Next by Date: Fourier coefficients
  • Previous by thread: Re: How to apply EdgeForm to ParametricPlot3D?
  • Next by thread: Re: Re: How to apply EdgeForm to ParametricPlot3D?