2
$\begingroup$

I am trying to plot several vector fields on a surface in MAPLE. It will be a random one, a tangent field, and a gradient field.

Specifically, I'm stuck trying to restrict a 3D field to the surface only. I may not have taken the right approach...

Here's a couple first tries. With a vector field :

eqn:=(x^2+3*y^2)*exp(1/2*(-x^2-y^2)):
montagne:=plot3d(eqn,x = -3 .. 3, y = -3.6 .. 3.6,shading=zgrayscale,grid=[300,300],scaling=unconstrained):
vect := VectorField(<sin(y),x,z>,cartesian[x,y,z], output=plot,view=[-3..3,-3..3,0..2.3],fieldoptions=[fieldstrength=fixed,arrows=SLIM,grid=[10,10,10],axes=none,color="Red"]):
display(montagne, vect, orientation = [30, 70]);

Here's the gradient (I know it's not elegant code, but I need the directional derivatives to make different examples) :

with(Student[MultivariateCalculus]):
f := (x, y) -> eqn:
dir1:=(x) -> DirectionalDerivative(z-f(x,y),[x,y,z],[1,0,0]):
dir2:=(y) -> DirectionalDerivative(z-f(x,y),[x,y,z],[0,1,0]):
dir3:=(z) -> DirectionalDerivative(z-f(x,y),[x,y,z],[0,0,1]):
gradf2 := VectorField(<dir1(x),dir2(y),dir3(z)>,cartesian[x,y,z], output=plot,view=[-3..3,-3..3,0..2.3],fieldoptions=[arrows=SLIM,grid=[10,10,10],axes=none,color="Red"]):
display(montagne, gradf2, orientation = [30, 70]);

And what it looks like :

enter image description here

Any idea how I can "cut the field" ? Or at least draw tangent vectors on the surface in a controlled manner ? Thanks for your help

$\endgroup$

1 Answer 1

1
$\begingroup$

You want to draw arrows at points on the surface. The arrow command in the plots package (or the plottools package) will be useful. Something like:

with(plots): with(VectorCalculus):
SetCoordinates(cartesian[x,y,z]):
eqn:=(x^2+3*y^2)*exp(1/2*(-x^2-y^2)):
montagne:=plot3d(eqn,x = -3 .. 3, y = -3.6 .. 3.6,shading=zgrayscale,
   grid=[300,300],scaling=unconstrained):
normals:= Gradient(z-eqn):
display(montagne,seq(seq(arrow([x,y,eqn],normals/2,colour=red),
   x=-3..3),y=-3..3),scaling=constrained);
$\endgroup$
3
  • $\begingroup$ Works well thanks, but why are they so long that they need to be cut in half in length ? I don't understand why their length are different than with the directional derivatives... $\endgroup$
    – Johann
    Dec 26, 2016 at 13:09
  • $\begingroup$ The lengths are whatever they are. You can scale them to taste. $\endgroup$ Dec 26, 2016 at 17:55
  • $\begingroup$ Sure, but what I mean is they should be the same length as the ones calculated with the directionnal derivatives in $\mathbb R^3$ (since in the directions of the basis vectors, they make the partial derivatives composing the gradient vector)... Shouldn't they ? Am I missing something ? $\endgroup$
    – Johann
    Dec 26, 2016 at 21:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .