3
$\begingroup$

I am trying to draw a sphere that is tangent to the three coordinate planes. I tried

Graphics3D[{Cyan, Sphere[{5, 5, 5}, 5]}, Boxed -> False, 
 PlotRange -> {{0, 12}, {0, 12}, {0, 12}}, ViewPoint -> {1, 1, 1}, 
 Lighting -> "Neutral", 
 FaceGrids -> 
  Table[{face, {Range[0, 12, 1], 
     Range[0, 12, 1]}}, {face, -IdentityMatrix[3]}], 
 PlotRangePadding -> 0]

enter image description here

Graphics3D[{{Red, Opacity[0.3], 
   InfinitePlane[{{0, 0, 0}, {10, 0, 0}, {0, 10, 0}}]},{Green, Opacity[0.3], 
   InfinitePlane[{{0, 0, 0}, {10, 0, 0}, {0, 0, 10}}]},{Blue, Opacity[0.3], 
   InfinitePlane[{{0, 0, 0}, {0, 10, 0}, {0, 0, 10}}]},Blue, Sphere[{5, 5, 5}, 5] }, Boxed -> False,
  PlotRange -> {{0, 10}, {0, 10}, {0, 10}}, ViewPoint -> {1, 1, 1}, 
 Lighting -> "Neutral"]

enter image description here

How can I get like this?

enter image description here

$\endgroup$
9
  • $\begingroup$ Do you mean to, like, change the ViewPoint? $\endgroup$
    – Michael E2
    Commented Nov 2 at 0:50
  • 1
    $\begingroup$ Maybe this: Rotate it around how you would like it. Select the output cell. Do the menu command Cell > Show Expression. Copy the ViewPoint and ViewVertical settings and paste the options into the original Graphics3D code. $\endgroup$
    – Michael E2
    Commented Nov 2 at 0:53
  • $\begingroup$ @MichaelE2 I have just edited. $\endgroup$ Commented Nov 2 at 1:02
  • $\begingroup$ I don't see much difference, in terms of pure planes and sphere, except that the sphere does not look tangent to the left wall. I assume you're not asking for the shadow and textures on the wall, floor, and ball, since these were not mentioned in the orignal post. $\endgroup$
    – Michael E2
    Commented Nov 2 at 1:05
  • $\begingroup$ Do you mean like this?: i.sstatic.net/Z4ZsXyEm.png $\endgroup$
    – Michael E2
    Commented Nov 2 at 1:34

1 Answer 1

3
$\begingroup$

By rotating, panning and zooming; and then examining the cell expression:

Graphics3D[{{Red, Opacity[0.3], 
   InfinitePlane[{{0, 0, 0}, {10, 0, 0}, {0, 10, 0}}]}, {Green, 
   Opacity[0.3], 
   InfinitePlane[{{0, 0, 0}, {10, 0, 0}, {0, 0, 10}}]}, {Blue, 
   Opacity[0.3], InfinitePlane[{{0, 0, 0}, {0, 10, 0}, {0, 0, 10}}]}, 
  Blue, Sphere[{5, 8, 5}, 5]}, BoxRatios -> Automatic, 
    Boxed -> False, 
    Lighting -> "Neutral", PlotRange -> 
      {{0, 16}, {0, 20}, {0, 16}}, ViewAngle -> 
      0.3650542014175573, ViewCenter -> 
      {{0.5, 0.5, 0.5}, {0.5497749751920034, 
          0.6460255657375193}}, ViewPoint -> 
      {1.3937013088594503, 0.937665108360899, 
        0.42235151976286206}, ViewVertical -> 
      {0.3018032845666661, 0.1620511984890498, 
        0.9394967730083135}]

enter image description here

$\endgroup$
3
  • $\begingroup$ Note I made the plot range a bit bigger, so that the zoom in would occupy the image rectangle. $\endgroup$
    – Michael E2
    Commented Nov 2 at 1:46
  • $\begingroup$ I don't understand when you used Sphere[{5, 8, 5}, 5] $\endgroup$ Commented Nov 2 at 2:22
  • $\begingroup$ @JohnPaulPeter Change the center to {5, 5, 5} as you had originally. I mentioned in a comment that it didn't appear to me that the ball was tangent to the left wall. It's a bit hard to tell, though, from just one perspective. That is what I showed. I figured whatever I showed, you would want to manipulate the graphics to your liking anyway. The key here, besides manipulating the graphics, is to use Show Expression to copy the option setting of the four View* options. You might change ViewVertical to Vertical -> {0,0,1} and see if you like that better. $\endgroup$
    – Michael E2
    Commented Nov 2 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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