I want to draw a solid or partially transparent hemisphere above a partially transparent cuboid object in Graphics3D
. However, I do not know how to do this such that only half the sphere is drawn. Here's what the object looks like with the full sphere:
SphereOpacity = 0.5;
CuboidOpacity = 0.5;
SphereColor = Blue;
CuboidColor = Orange;
Graphics3D[{SphereColor, Opacity[SphereOpacity], Sphere[{0, 0, 0.5}, 0.5],
CuboidColor, Opacity[CuboidOpacity], Cuboid[{-5, -5, 0}, {5, 5, 0.5}]},
Boxed -> False
]
How might I proceed to "remove" the bottom half the sphere embedded in the cuboid primitive? In general, is there a way to not render/draw parts of a graphics primitive conditioned intersection with another primitive?
Answer
ParametricPlot3D[{Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]},
{u, 0, π}, {v, 0, π},
Mesh -> None,
Boxed -> False,
Axes -> None
]
r = 0.5;
d = {0, 0, 0.5}
sphere = ParametricPlot3D[r {Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]} + d,
{u, -π/2, π/2}, {v, -π/2, π/2},
Mesh -> None, Boxed -> False, Axes -> None][[1]];
SphereOpacity = 0.5;
CuboidOpacity = 0.5;
SphereColor = Blue;
CuboidColor = Orange;
Graphics3D[{SphereColor, Opacity[SphereOpacity], sphere, CuboidColor,
Opacity[CuboidOpacity], Cuboid[{-5, -5, 0}, {5, 5, 0.5}]},
Boxed -> False]
Comments
Post a Comment