7
$\begingroup$

Simple question I can't figure out. Is it possible to smooth the edge faces of a capsule, or is this inherent to the mesh underlying the capsule? This is just for visualization purposes, I don't really care about changing any inherent properties of the mesh/region.

Maybe a workaround would be some sort of lighting option that ignores the edges? Which option(s) would that be?

Note: I'm on Windows 10 and MMA 13.1.

Thanks!

myCapsules = {CapsuleShape[{{-0.5, 0., 0.}, {0.5, 0., 0.}}, 5.], 
 CapsuleShape[{{-7.55082, 3.30872, -3.61074}, {-7.13133, 
    3.12491, -3.41015}}, 5.]};

Graphics3D[myCapsules, ViewPoint -> Front, Axes -> True, AxesLabel -> {X, Y, Z}]

enter image description here

$\endgroup$
2
  • 3
    $\begingroup$ This may be OS and version dependent. I am on MMA 12.3.1 on Win10-64 and the results of your unmodified code are much, much smoother already. $\endgroup$
    – MarcoB
    Jul 13, 2022 at 18:52
  • $\begingroup$ @MarcoB That's strange, I'd think the latest version would render the best XD. Or maybe it is Windows. Thanks for checking! $\endgroup$ Jul 13, 2022 at 20:16

3 Answers 3

5
$\begingroup$

I get better-looking results if I use Tube[] instead, and tweak the internal "TubePoints" setting:

Graphics3D[{Tube @@@ myCapsules}, ViewPoint -> Front,
           Axes -> True, AxesLabel -> {X, Y, Z}, Method -> {"TubePoints" -> 30}]

short, fat tubes

I am not aware if there's a similar internal option setting corresponding to CapsuleShape[], which would be a direct answer to your question.

$\endgroup$
5
$\begingroup$

To increase the quality of the picture, you may increase the "SplinePoints":

Graphics3D[myCapsules, ViewPoint -> Front, Axes -> True, 
 AxesLabel -> {X, Y, Z}, Method -> {"SplinePoints" -> 15}]

enter image description here

$\endgroup$
5
$\begingroup$

Or use AccuracyGoal -> 3 in DiscretizeRegion.

myCapsules = {CapsuleShape[{{-0.5, 0., 0.}, {0.5, 0., 0.}}, 5.], 
   CapsuleShape[{{-7.55082, 3.30872, -3.61074}, {-7.13133, 
      3.12491, -3.41015}}, 5.]};
myCapsules = 
 BoundaryDiscretizeRegion[#, AccuracyGoal -> 3] & /@ myCapsules
Graphics3D[{EdgeForm[], myCapsules}, ViewPoint -> Front, Axes -> True,
  AxesLabel -> {X, Y, Z}]

enter image description here

$\endgroup$

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.