Mathematica中的绘图点

时间:2011-10-27 02:20:19

标签: wolfram-mathematica

我试图在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

(它们应该看起来像表面上的点)

我想要做的是使用ListPointPlot3D在另一个图表上手动输入点的坐标,然后使用Show将它们组合起来。但由于某种原因,这是行不通的。建议?

另外,我想在x方向上添加与表面相切的小矢量作为我绘制的点,但我不知道如何做到这一点,所以建议非常感谢!

3 个答案:

答案 0 :(得分:8)

也许这可以帮助您开始使用解决方案。它在表面上绘制了3个随机点。您可以通过设置nPoints来更改点数。我不知道如何在x上绘制切线。但是当你弄明白时,你可以使用Arrow,如@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

修改

以下动态变化利用了@belisarius的贡献:

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

答案 1 :(得分:5)

对于箭头

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

为了使箭头朝向任何方向a = {a1,a2}而不是x,你可以这样做:

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

修改

衍生品和正常:

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

答案 2 :(得分:1)

您可以使用Graphics3D[listofpoints]将图表与点组合,其中listofpoints是T * 3矩阵列表,箭头使用Graphics3D[Arrow[{{1, 1, -1}, {2, 2, 0}, {3, 3, -1}, {4, 4, 0}}]]等结构。如果它们都是Graphics3D个对象,您应该能够将它们与Show组合在一起。

抱歉,我现在不在Mathematica安装附近为您提供示例。