8

I would like to add a black outline (silhouette) all around a closed surface. Here's a MWE code to work with :

Manipulate[
    SphericalPlot3D[1, {theta, 0, Pi}, {phi, t, 2Pi + t},
        Mesh -> {7, 7},
        MaxRecursion -> ControlActive[2, 5],
        PlotRange -> All,
        Boxed -> False,
        Axes -> None,
        SphericalRegion -> True,
        Method -> {"RotationControl" -> "Globe"},
        ImageSize -> {500, 500}
    ],
    {{t, 0, Style["t", 10]}, 0, 2Pi, 0.01}
]

So is it possible to draw a thin line all around that sphere, to make it standing out of the white background ?

EDIT : By "outline" (or "silhouette", or "profile"), I mean some curve like the circle around the ball shown below (the outline should be made for any surface, not just for the sphere defined in the code above !)

a sphere with an outline

The outline should be drawn around the whole surface's exterior, and don't apply to parts inside the surface (except if it has holes).

Cham
  • 4,093
  • 21
  • 36
  • An incredibly stupid and impractical hack that works in this case (of a perfect sphere) would be adding a Prolog -> Inset[Graphics[Disk[], ImageSize -> 300]]] as an option. Some sort of Inset solution might actually be of use even on the final solution. – kirma Mar 08 '16 at 17:17
  • BTW, can you clarify if you want to have this outline only between the background and the object, or possibly also between the object and parts of itself it occludes? – kirma Mar 08 '16 at 17:32
  • 1
    If you draw a black outline around the whole surface of the sphere, you will not be able to see the sphere. – bill s Mar 08 '16 at 18:06
  • @bills Heh heh, being overly pedantic... :) – kirma Mar 08 '16 at 18:33
  • @bills, LOL ! Ok, I'll edit the question, to precise the idea of a "silhouette". – Cham Mar 08 '16 at 19:42
  • 3
    It will be hard to make responsive general solution, here's something closely related: Sketch-type graphics with transparency and dashed hidden lines? – Kuba Mar 08 '16 at 19:58
  • I may be wrong, but I believed that there are some standard options in Mathematica to do this. – Cham Mar 08 '16 at 20:33
  • See http://mathematica.stackexchange.com/a/99452/484 –  Mar 08 '16 at 20:37
  • Can Mathematica drop a shadow under (or behind) a 3D surface ? – Cham Mar 08 '16 at 20:48
  • 1
    About the drop shadow idea : http://mathematica.stackexchange.com/questions/938/how-to-make-a-drop-shadow-for-a-graphics3d-objects – Cham Mar 08 '16 at 20:59
  • @Cham could you comment on what doesn't work for you in the solution presented in How to make a drop-shadow for a Graphics3D objects?, the post you mentioned above? – MarcoB Mar 09 '16 at 03:41
  • 1
    @MarcoB, I'm giving up the outline idea because it will certainly not work with my old version 7, or it will have a very high impact on performances under a Manipulate box. The shadow codes don't work for me. – Cham Mar 09 '16 at 13:20
  • Highlighting the edge of a sphere or other arbitrary and possibly smooth object is a problem (well, not really a problem, just a convention) of engineering graphics/drafting/sketching. I would suggest to all would be answerers to consider the problem from their standpoint. When these people draw 3D representations of objects they design, they do not think of their drawing as a 3D image. On the contrary, they are constructing a certain projection of a 3D object onto a 2D plane. A sphere always becomes a circle, and thus has a well defined boundary. – LLlAMnYP Mar 11 '16 at 22:09
  • The only additional solid lines are then those, that are captured by the EdgeForm function. @Kuba is spot on with his related linking, and I don't think there's much to add to that, but another possible approach would indeed be to construct projections of Graphics3D scenes onto planes. – LLlAMnYP Mar 11 '16 at 22:11

1 Answers1

3

Although, this may not be the best answer. I thought I post it for fun.

Input:

core = {Red, Sphere[{0, 0, 0}, 1.9]};
outline = {Yellow, Opacity[0.5], Sphere[{0, 0, 0}, 2]};

Graphics3D @ {core, outline}

Output:

output example

EDIT:

Alternatively, you could probably mess around with lighting property. Here is an example:

sphere1 = Graphics3D[core, Lighting -> {{"Ambient", White}}];
sphere2 = Graphics3D[outline];

Show[sphere1, sphere2]

And the output of this would be something like:

output2

EDIT:

Some additional way how to modify edges:

Graphics3D[{EdgeForm[{Thick, Black}], 
    FaceForm[White], #}] & /@ {Cuboid[], 
  Polygon[{{1, 0, 0}, {1, 1, 1}, {0, 0, 1}}]}

With the associated output:

output 3

Reference:

Sphere
Graphics3D
Opacity

e.doroskevic
  • 5,959
  • 1
  • 13
  • 32
  • What would you do if you want a black outline ? The transparency trick will not work in this case. You may have to duplicate the surface, one in full black, behind the normal surface, but then there will be a problem of intersection and depth sorting... – Cham Mar 11 '16 at 20:01
  • I am afraid my WPL skills aren't at that level to deliver what you've requested in your original post. The only reason why I've added this solution is to share my ideas in relation to your question. – e.doroskevic Mar 11 '16 at 20:48
  • Just for curiosity, what is WPL ? – Cham Mar 11 '16 at 20:54
  • Wolfram programming language – e.doroskevic Mar 11 '16 at 21:10
  • The last edit appears to be highly interesting. I don't have access to Mathematica right now, and I can't wait to try this code (EdgeForm and FaceForm). – Cham Mar 11 '16 at 21:50
  • What are the differences between FaceForm, EdgeForm and Mesh ? – Cham Mar 11 '16 at 21:55
  • @Cham The names should speak for themselves, shouldn't they? FaceForm passes directives to the sides of the cube, the big squares from which it is assembled, EdgeForm, well, acts on the edges... I really can't come up with a synonym for them. EdgeForm is really what you're looking for, but unfortunately in MMA it seems to work only on sharp corners, like those of a polyhedron. If it's a smooth surface, like the edge of a sphere then there aren't any explicit edges to highlight. – LLlAMnYP Mar 11 '16 at 22:04
  • @LLlAMnYP, what I don't understand is that any surface in MMA are made of polygons, with an edge. So for the moment (I still don't have access to MMA right now), I don't see what FaceForm and EdgeForm could do, relative to Mesh. – Cham Mar 11 '16 at 22:13
  • @Cham I don't think Mesh is too related here. Not any surface is polygonal in MMA. Graphics3D[Sphere[]]//InputForm returns Graphics3D[Sphere[{0,0,0}]] so it doesn't have edges. PS my bad, the entire surface of the sphere is regarded as a face though. – LLlAMnYP Mar 11 '16 at 22:16
  • @LLlAMnYP, a MMA sphere is still made of lots of small triangles. The polygonal shape can easily be seen at close range. I guess I'll have to try the FaceForm and EdgeForm later, to understand what they do. – Cham Mar 11 '16 at 22:19
  • @Cham that may be how MMA renders it, but it does not regard a sphere as a set of polygons. EdgeForm does not influence anything about Sphere[]. – LLlAMnYP Mar 11 '16 at 22:22
  • @LLlAMnYP, so if you try to use FaceForm and EdgeForm on a surface defined by some smooth functions, what do you get ? Take for example the surface {Sin[theta]Cos[phi], Sin[theta]Sin[phi], Cos[theta]} (a sphere in parametric plot, not as a MMA primitive). What would you get ? – Cham Mar 11 '16 at 22:27
  • @Cham yes, that will be a collection of polygons with the expected behavior of EdgeForm. – LLlAMnYP Mar 11 '16 at 22:37
  • @LLlAMnYP, could you try it and add it to your answer ? EdgeForm and FaceForm to a sphere in parametric form ? – Cham Mar 11 '16 at 22:39