Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting points in Mathematica

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!

like image 397
alice314159 Avatar asked Oct 27 '11 02:10

alice314159


2 Answers

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

like image 37
Dr. belisarius Avatar answered Oct 07 '22 00:10

Dr. belisarius


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

like image 157
DavidC Avatar answered Oct 06 '22 23:10

DavidC