\(\(\( (*\ \(:\)\(Title : Arrow\ 3  D\)*) \)\( (*\ \(:\)\(Context : 
          Graphics`Arrow3D`\)*) \)\( (*\ \(:\)\(Author : 
          John\ M . Novak\)*) \)\( (*\ \(:\)\(Summary : 
          crude\ 3  D\ arrow\ primitive\)*) \)\( (*\ \(\(:\)\(Copyright : 
          Copyright\ 1996\ Wolfram\ Research\)\), \(\(Inc\)\(.\)\)*) \)\( (*\ \(:\)\(Package\ \(Version : 
            1.0\)\)*) \)\( (*\ \(:\)\(Mathematica\ \(Version : 
            3.0\)\)*) \)\( (*\ \(:\)\(History : 
          V1 \( .0--\)\ March\ 1996\ by\ John\ M . 
              Novak\)*) \)\( (*\ \(\(:\)\(Keywords : arrow\)\), 
      Graphics3D*) \)\( (*\ \(\(:\)\(Sources : 
          Tom\ Wickham - 
            Jones\)\), "Mathematica Graphics"*) \)\( (*\ \(\(:\)\(Discussion : 
          This\ is\ a\ package\ to\ add\ crude\ 3  D\ arrows\ by\ using\ 3  
            D\ graphics\ primitives . 
              The\ main\ problem\ with\ this\ approach\ is\ that\ arrows\ don' t\ have\ an\ optimal\ appearance\)\), 
      and\ distinction\ between\ \((e . g . )\)\ arrows\ point\ toward\ vs . 
          away\ from\ the\ user\ is\ difficult\ to\ make . 
          On\ the\ other\ hand, it\ is\ readily\ implementable, 
      which\ is\ far\ superior\ to\ any\ other\ approach\ available\ at\ this\ time . \((The\ PostScript\ used\ in\ 2  D\ arrows\ won' 
              t\ layer\ correctly\ in\ 3  D, nor\ would\ 2  D\ primitives; 
            placing\ 3  
              D\ planar\ primitives\ with\ the\ correct\ orientation\ has\ problems\ with\ perspective\ transforms\ as\ well\ as\ design\ problems\ with\ things\ like\ arrows\ with\ a\ small\ angle\ w . r . t . 
                the\ \(\(user\)\(.\)\))\)\ Because\ of\ the\ essentially\ different\ approach\ from\ 2  D\ arrows, 
      the\ package\ is\ being\ made\ independent\ of\ the\ 2  
        D\ package\ for\ the\ time\ \(\(being\)\(.\)\)*) \)\(BeginPackage["Graphics`Arrow3D`"]


    \(Arrow3D::usage = "Arrow3D[start, end] is a 3D graphics primitive representing an arrow in
space. The start point and the end point are given as {x, y, z}
triplets.
Options controlling the length and width of the arrowhead are
available.";\)


    Begin["`Private`"]

 (*The\ following\ routine\ is\ based\ on\ OrthogonalVectors\ from\ Tom\ Wickham - 
        Jones'\ Mathematica\ Graphics\ \(\(book\)\(.\)\)*) 


    anOrthogonalVector[norm : {_, _, _}] := 
      Block[{pos, a, b, v1}, 
        pos = If[VectorQ[norm, NumberQ], Abs[N[norm]], 
            norm]; 
pos = 
          Sort[Transpose[{pos, Range[3]}]]; 
{pos, a, b} = 
          Map[Last, pos]; 
v1 = 
          ReplacePart[{0, 0, 0}, \(-Part[norm, a]\), 
            b]; 
ReplacePart[v1, Part[norm, b], 
          a]]


    normalize[vec_] := 
      vec/Sqrt[vec . 
            vec]

 (*The\ following\ routine' rotationmatrix'\ was\ borrowed\ from\ the\ standard\ package\ \(\(Graphics`SurfaceOfRevolution`\)\(.\)\)*) 


    rotationmatrix[axis_, theta_] := 
      Module[{n1, n2, n3}, {n1, n2, n3} = 
          normalize[axis] // 
            N; 
{{n1^2 + \((1 - n1^2)\)\ Cos[theta], 
              n1\ n2\ \((1 - Cos[theta])\) + n3\ Sin[theta], 
              n1\ n3\ \((1 - Cos[theta])\) - 
                n2\ Sin[theta]}, {n1\ n2\ \((1 - Cos[theta])\) - 
                n3\ Sin[theta], n2^2 + \((1 - n2^2)\)\ Cos[theta], 
              n2\ n3\ \((1 - Cos[theta])\) + 
                n1\ Sin[theta]}, {n1\ n3\ \((1 - Cos[theta])\) + 
                n2\ Sin[theta], 
              n2\ n3\ \((1 - Cos[theta])\) - n1\ Sin[theta], 
              n3^2 + \((1 - n3^2)\)\ Cos[theta]}} // N]


    Arrow3D[base : {_, _, _}, tip : {_, _, _}, polys_:  10, 
        len_:  0.8] := {Line[{base, tip}], 
        mycone[tip - base, base, tip, polys, len]}


    Arrow3D[base : {_, _, _}, tip : {_, _, _}, ___] := 
      Point[base] /; base == tip


    mycone[vec_, base_, tip_, polys_, len_] := 
      Block[{norm = anOrthogonalVector[vec], theta}, 
        Map[Polygon[Append[#, tip]] &, 
          Partition[
            Table[base + 
                  len\ vec + \((1 - len)\)/2\ norm . 
                      rotationmatrix[vec, theta], {theta, 0, 2\ Pi, 
                  2\ Pi/polys}] // N, 2, 1]]]


    End[]


    EndPackage[]



    \("Graphics`Arrow3D`";\)

    \("Arrow3D[start, end] is a 3D graphics primitive representing an arrow in space. The start point and the end point are given as {x, y, z} triplets. Options controlling the length and width of the arrowhead are available.";\)

    \("Graphics`Arrow3D`Private`";\)

    \("Graphics`Arrow3D`Private`";\)

    \)\)\)

\(MATH\ 257\ Calculus\ III				Week\ of\ May\ 26, \ 2003\)
Lab 9 :  Parametric Surfing
Name 1
Name 2
Section:

Parametric Surfaces

Before we used the command ParametricPlot3D[] to graph things of the form {x[t],y[t],z[t]}, and this would graph a space curve for us.

NOW we'll use the same command to graph surfaces that we parameterize.  This means that now we'll use things of the form {x[u,v],y[u,v],z[u,v]}.  That is, we'll have TWO parameters now!

Example:  Let's graph the surface <(2+Sin[v])Cos[u], (2+Sin[v])Sin[u], u+Cos[v]>:

r[u_, v_] = {(2 + Sin[v]) Cos[u],  (2 + Sin[v]) Sin[u],  
        u + Cos[v]}
ParametricPlot3D[
      r[u, v] // Evaluate, 
{u, 0, 4  π},  {v, 0, 
        2  π},  PlotPoints -> {40, 20}]

Question 1: Describe in words and make a plot what curve(s) we would get if we
	(a) held the parameter v constant (and let u roam free)
	(b) held the parameter u constant (and let v roam free).
(Hint: you can actually see them in the 3D plot above.)

Question 2: Do the same thing with Dini's Surface:  (That is, make a surface plot and then graph some curves that hold u and then v constant.) (I recommend  0 ≤ u ≤ 7π and try  .01 ≤ v ≤ 2.  Then try .01 ≤ v ≤ 2.6.  ViewPoint->{0.258, -3.373, -0.093}  is a good one.)

dini[u_, v_] = {1.5  Cos[u] Sin[v],  
        1.5  Sin[u] Sin[v],  
        1.5 (Cos[v] + Log[Tan[v/2]]) +  .2  u}

Parameterizing Planes

Suppose we were given a point r0=(x0,y0,z0) and two nonparallel vectors a and b.  How might we parameterize the plane that contains the two vectors and the point?

It's actually pretty easy.  If u and v are your parameters, all you have to do is define
	r(u,v) = r0 +ua + vb
to get a parameterization of a surface.  The question is: can you take it from there to do it on Mathematica?

Question 3: Find and graph a parameterization of the plane that contains the vectors a=<1,2,3> and b=<-5,-3,1> that also passes through the point r0=(17,5,5).

Surfaces of Revolution

Remember in Calc II when we found the volume of solids of revolution?  Wasn't that fun?  Actually, it would have been a lot more fun if we had Mathematica at the time to graph those darn surfaces for us!

In Calc II, you would have been given a function like y = (x^2), and asked to take this curve from 0 ≤ x ≤ 2 (or something like that) and rotate it around the x-axis.  When rotating this, we're really creating circles in the y-z plane, right?  So if we parameterize like so:
		x = 
        x ,       y = (x^2) 
          Cos[θ],      z  =  (x^2) Sin[θ]
and let x and θ be our parameters, it should work, right?

Question 4a: Use the above parameterization to make a parameterized surface plot of the surface of revolution for y = (x^2) from 0 ≤ x ≤ 2 when rotated about the x-axis.

Question 4b: Make a picture of the surface of revolution generated by rotating y=Sin[x] from 0 ≤ x ≤ 4π about the x-axis.

Question 4c: Make a picture of the surface of revolution generated by rotating y = x - (x^2) from 0 ≤ x ≤ 1 about the y-axis.

Now that you're done, 
	(1) 	Clean up your work by deleting everything that's not needed.  
		There should only be the title, your names, section number, and the questions and your answers
		(with any needed explanations, graphs, etc.).
	(2) 	Save this to your disk.
	(3)	Go back to Blackboard and upload your final lab report to the Digital Drop Box, located
		in the User Tools area.  Remember that you have to first ADD your file to your digital drop box and 
		then SEND it to me!
Note:  these graphic images can get BIG.  Make sure you DELETE any images that you do not need for your answers.  This will reduce the chances of something going wrong when you upload it to Blackboard.