wolfram-mathematicagraphics3d

Sphere Styling and Grid Spacing in Graphics3D


Please consider :

colors = {Red, Green, Blue};
style = {Thickness[.01], Thickness[.01], Thickness[.01]};
cAxes = {{{0, 0, 0}, {0, 0, 1}}, {{0, 0, 0}, {0, 1, 0}}, {{0, 0, 
 0}, {1, 0, 0}}};

Graphics3D[{{#1, #2, Line@#3} & @@@ Transpose@{colors, style, cAxes}, 
Blue, Specularity[White, 3], Sphere[{.5, .5, .5}, .1]}, 
Boxed -> False, FaceGrids -> All, 
FaceGridsStyle -> Directive[Black, Dashed]]

Using Yoda`s solution on How to Style Lines

How could I color the Sphere using GrayLevel (I will manipulate it later).

And How could I have denser FaceGrids ? 10 Lines horizontally & Vertically. I also don`t understand why the Edges one are distant to one another.

enter image description here


Solution

  • It's always good practice to group the graphics object and its styles in a list, in case you need to quickly add another one with different styles. By that, I mean write it as {Blue, Specularity[White, 3], Sphere[{.5, .5, .5}, .1]}. Now you can easily add a GrayLevel term before Sphere and it'll work.

    For the FaceGrids, I believe you'll have to manually define the lines at your desired spacing for each face. Here's an example for showing how to do it for one face.

    Graphics3D[{{#1, #2, Line@#3} & @@@ 
       Transpose@{colors, style, cAxes}, {Blue, GrayLevel[0.3], Lighting -> "Neutral",
       Specularity[White, 3], Sphere[{.5, .5, .5}, .1]}}, Boxed -> False, 
     FaceGrids -> {{{0, 0, 1}, 
        Transpose@({#, #} & /@ Range[0, 1, 0.1])}}, 
     FaceGridsStyle -> Directive[Black, Dashed]]
    

    enter image description here

    The faces are defined as ±1 for the corresponding plane and the other two are zero. So {0,0,1} in my example corresponds to the z=1 plane.

    The list supplied to FaceGrids can be easily computed for each face, instead of manually entering them, but I'll leave that to you :)

    EDIT:

    Since you want a uniform mesh all around, define where you want the grid lines drawn as

    gridList = Transpose@({#, #} & /@ Range[0, 1, 0.1]);
    

    Then, use the following for FaceGrids:

    FaceGrids -> Join @@ Table[{RotateLeft[j {0, 0, 1}, i], gridList}, 
        {i, {0, 1, 2}}, {j, {-1, 1}}]
    

    Here's how the result should look like with PlotRangePadding -> None:

    enter image description here