10
votes

I am trying to plot a few points on the following picture in Mathematica:

ParametricPlot3D[
   {{u, v, (Cos[u] + Cos[v])/3}, {u, -1, (Cos[u] + Cos[0])/3}, 
   {5, v, (Cos[4] + Cos[v])/3}}, {u, -4, 4}, {v, 0, 8}, Axes -> False, 
 Boxed -> False, BoxRatios -> {8, 8, 1.5}]

Mathematica graphics

(they should just look like dots on the surface)

What I was trying to do is enter the coordinates of the points manually on another graph using ListPointPlot3D, and then combine them using Show. But for some reason that isn't working. Suggestions?

Also, I would like to add small vectors tangent to the surface in the x directions for the points I have plotted, but I have no idea on how to do that, so suggestions would be very much appreciated!

3
By the way, welcome to StackOverflow. Remember to accept the answer that best answers your question, by clicking on the checkmark next to that answer. Once you have a bit more reputation, you can do things like upvote good answers (and questions), and comment on posts that are not your own. You might also be interested to check out the proposal for a dedicated Mathematica users site in the StackExchange network: area51.stackexchange.com/proposals/15787/mathematica - Verbeia

3 Answers

8
votes

Perhaps this will help you get started on a solution. It plots 3 random points on the surface. You can change the number of points by setting nPoints. I don't know how to plot tangents along x. But when you figure that out you can use Arrows, as suggested by @Verbeia.

nPoints = 3;
Show[ParametricPlot3D[{
       {u, v, (Cos[u] + Cos[v])/3}, 
       {u, -1, (Cos[u] + Cos[0])/3}, {5,  v, (Cos[4] + Cos[v])/3}}, 
       {u, -4, 4}, {v, 0, 8}, Axes -> False, 
       Boxed -> False, BoxRatios -> {8, 8, 1.5},
       PlotStyle -> Directive[Opacity[0.5]]],

     Graphics3D[{Red, PointSize[.025], 
         Point[Table[{u1 = RandomReal[{-3, 3}], v1 = RandomReal[{1, 7}], 
         (Cos[u1] + Cos[v1])/3}, {nPoints}]]}]]

points on surface

Edit

The following dynamic variation makes use of @belisarius 's contribution:

Manipulate[
Show[ParametricPlot3D[{{u, v, (Cos[u] + Cos[v])/3} },
  {u, -4, 4}, {v, 0, 8}, Axes -> False, Boxed -> False, 
  BoxRatios -> {8, 8, 1.5},
  Mesh -> None,
  ImageSize -> {400, 300},
  PlotRange -> {{-4, 4}, {0, 8}},
  PlotRangePadding -> {{0, 1.4}, {0, 0}},
  PlotStyle -> Directive[Opacity[0.5]]],
Graphics3D[({Red, PointSize[.025], 
  Point@f[pt[[1, 1]], pt[[1, 2]]], Black, 
  Arrow[{f[pt[[1, 1]], pt[[1, 2]]], 
  f[pt[[1, 1]], pt[[1, 2]]] + D[f[t, pt[[1, 2]]], t] /. 
   t -> pt[[1, 1]]}]}]],
Grid[{{
  LocatorPane[Dynamic[pt],
  Dynamic[Graphics[{},
   PlotRange -> {{-4, 4}, {0, 8}},
   Frame -> True,
   ImageSize -> 160,
   FrameTicks -> {Range[-4, 4], Range[0, 8], None, None},
   FrameLabel -> {"u", "v"},
   GridLines -> {Range[-4, 4], Range[0, 8]},
   GridLinesStyle -> Directive[LightGray]]],
   {{-4, 0}, {4, 8}}]}}],
  {{pt, {{1, 2}}}, ControlType -> None},

  Initialization :> {f[u_, v_] := {u, v, (Cos[u] + Cos[v])/3};}]

Manipulate

5
votes

For the Arrows

f[u_, v_] := {u, v, (Cos[u] + Cos[v])/3};
Show[ParametricPlot3D[{f[u, v]}, {u, -4, 4}, {v, 0, 8},
         Axes -> False,  Mesh -> None, Boxed -> False, BoxRatios -> {8, 8, 1.5}, 
         PlotStyle -> Directive[Opacity[0.5]]], 
 Graphics3D@
  Table[{Red, PointSize[.025], Point@f[u, v], 
         Black, Arrow[{f[u, v], f[u, v] + D[f[t, v], t] /. t -> u}]}, 
  {u, -4, 4, 2}, {v, 0, 8, 2}]]

enter image description here

For getting the arrows in any direction a = { a1, a2 } instead of x, you may do:

Dot[{a1,a2}.#] & /@ D[f[u, v], {{u, v}}]
(*
-> {a1, a2, -(1/3) a1 Sin[u] - 1/3 a2 Sin[v]}
*)

Edit

Both derivatives and normal:

f[u_, v_] := {u, v, (Cos[u] + Cos[v])/3};
Show[
 Graphics3D@
  Table[{Red, PointSize[.025], Point@f[u, v], Black, Arrowheads[.02], 
    Arrow[{f[u, v], f[u, v] + D[f[t, v], t] /. t -> u}], 
    Arrow[{f[u, v], f[u, v] + D[f[u, t], t] /. t -> v}],
    Arrow[{f[u, v],  f[u, v] +
                     Cross[D[f[t, v], t] /. t -> u, 
                           D[f[u, t], t] /. t -> v]}]}, 
  {u, -4, 4, 2}, {v, 0, 8, 2}], 

 ParametricPlot3D[{f[u, v]}, {u, -4, 4}, {v, 0, 8}, 
     Axes -> False, Mesh -> 3, MeshStyle -> {{Opacity[0.1], LightBlue}}, 
     Boxed -> False, BoxRatios -> {8, 8, 1.5}, 
     PlotStyle -> Directive[Opacity[0.5]]]]

enter image description here

1
votes

You can combine the plot with points using Graphics3D[listofpoints], where listofpoints is a T*3 matrix list, and the arrows using constructs like Graphics3D[Arrow[{{1, 1, -1}, {2, 2, 0}, {3, 3, -1}, {4, 4, 0}}]]. If they are all Graphics3D objects, you should be able to combine them with Show.

Sorry, I am not near a Mathematica installation to provide you with an example just now.