2
$\begingroup$

I would like to plot a point (in a shape of a small sphere) lying on the surface $z=10-x^{2}-y^{2}$. But it seems that the spherical point is being distorted. How can I make it round?

This is my code:

Show[Plot3D[10 - x^2 - y^2, {x, 0, 3.3}, {y, 0, 3.3}, 
  PlotStyle -> Opacity[0.4], Mesh -> None, 
  PlotStyle -> Thickness[0.02], PlotRange -> {-1, 12}, 
  AxesStyle -> Thick, Boxed -> False, AxesOrigin -> {0, 0, 0}, 
  AxesLabel -> {x, y, z}], Graphics3D[{Blue, Sphere[{1, 2, 5}, 0.2]}],
  BoxRatios -> {1, 1, 1}]

enter image description here

$\endgroup$
  • 3
    $\begingroup$ Use BoxRatios -> Automatic instead of {1,1,1}. $\endgroup$ – Artes Jan 21 at 10:30
  • $\begingroup$ @Artes Thanks so much. It works. $\endgroup$ – Binjiu Jan 21 at 10:31
3
$\begingroup$

If you want to keep BoxRatios -> {1, 1, 1}, you can do

plt1 = Plot3D[10 - x^2 - y^2, {x, 0, 3.3}, {y, 0, 3.3}, 
   PlotStyle -> Opacity[0.4], Mesh -> None, 
   PlotStyle -> Thickness[0.02], PlotRange -> {-1, 12}, 
   AxesStyle -> Thick, Boxed -> False, AxesOrigin -> {0, 0, 0}, 
   AxesLabel -> {x, y, z}];

pr = PlotRange[plt1];

br = {1, 1, 1};

scale = Norm[Subtract @@ Transpose[pr]] Normalize[-Subtract @@@ pr]/br;

Show[plt1, Graphics3D[{Blue, Scale[Sphere[{1, 2, 5}, .1], scale]}], 
 BoxRatios -> br]

enter image description here

With br = {1, 1, 3} we get

enter image description here

and with br = {1, 3, 2} we get

enter image description here

Update: "... add an arrow (normal vector) to the point":

plt1 = Show[
   Plot3D[10 - x^2 - y^2, {x, 0, 3.3}, {y, 0, 3.3}, 
    PlotStyle -> Opacity[0.4], Mesh -> None, 
    PlotStyle -> Thickness[0.02], PlotRange -> {-1, 12}, 
    AxesStyle -> Thick, Boxed -> False, AxesOrigin -> {0, 0, 0}, 
    AxesLabel -> {x, y, z}], 
   Graphics3D[{Red, Thickness[.01], Arrowheads[.04], 
     Arrow[{{1, 2, 5}, {3, 6, 6}}]}], PlotRange -> All];
pr = PlotRange[plt1];
br = {1, 1, 1};
scale = Norm[Subtract @@ Transpose[pr]] Normalize[-Subtract @@@ pr]/br;

Show[plt1, Graphics3D[{Blue, Scale[Sphere[{1, 2, 5}, .1], scale]}], 
 BoxRatios -> br]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks so much. This is what I am looking for. Keeping the prescribed ratio has some avantages. $\endgroup$ – Binjiu Jan 21 at 10:58
  • $\begingroup$ From a mathematical point of view your solution makes a confusion since a small sphere is always simply a sphere, while the graph of the function is being rescaled, even though one can believe it is a good Mathematica approach. $\endgroup$ – Artes Jan 21 at 11:12
  • $\begingroup$ @Artes I understand that it is not a good Math point of view, but in my opinion, it's useful as a good way to present Math to general audiences, who may only accept that a small point on a surface should appear like a small sphere. $\endgroup$ – Binjiu Jan 21 at 20:22
  • $\begingroup$ @Artes, excellent point. The different scalings for the surface and the small sphere actually means the two are on different coordinate systems and the axes of the latter not explicitly drawn. $\endgroup$ – kglr Jan 21 at 20:56
  • $\begingroup$ @kglr Hi, could you manage the same thing if I add an arrow (normal vector) to the point: Graphics3D[{Red, Thickness[.01], Arrowheads[.04], Arrow[{{1, 2, 5}, {3, 6, 6}}]}] $\endgroup$ – Binjiu Jan 21 at 23:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.