5
$\begingroup$

I'm trying to create a graphic for an inclined manometer and need to make the fluid in the manometer tube look realistic. The part where the blue and green tubes meet should be flat, like a real liquid. The red disk at that point represents what I need it to look like.

enter image description here

enter image description here

The angle is changed with a slider in Manipulate. I tried to make the solutions from this post work but failed. How can I take a slice out of a tube/cylinder that is at an angle?

Here is my code to work from to make the graphic:

Manipulate[
 Graphics3D[{
   Blue,
   Tube[{{-2.5, 0, 0}, {0, 0, 0}, {10*Cos[theta], 0, 10*Sin[theta]}}, 
    1.25],

   Green,
   Tube[{{10*Cos[theta], 0, 10*Sin[theta]}, {15*Cos[theta], 0, 
      15*Sin[theta]}, {15*Cos[theta] + 2.5, 0, 15*Sin[theta]}}, 1.25],

   }, ViewPoint -> Front],
 Control[{{theta, Pi/6}, Pi/6, Pi/4}]
 ]
$\endgroup$
1
  • 2
    $\begingroup$ Tube[] itself can't be cut off, so starting from lower-level primitives (i.e. Polygon[]) would be necessary here. Are those bends needed, or are you fine with a solution that just generates a truncated cylinder? $\endgroup$ Jan 31, 2017 at 16:40

1 Answer 1

8
$\begingroup$

You could use the ClipPlanes option. For example:

Manipulate[
  Graphics3D[{
    Style[
      Tube[{{-2.5, 0, 0}, {0, 0, 0}, {15*Cos[theta], 0, 15*Sin[theta]}}, 1.25],
      Blue,
      ClipPlanes -> InfinitePlane[{{0, 0, 10*Sin[theta]},
        {1, 0, 10*Sin[theta]}, {0, -1, 10*Sin[theta]}}]
    ],
    Style[
      Tube[{{0, 0, 0}, {15*Cos[theta], 0, 15*Sin[theta]},
        {15*Cos[theta] + 2.5, 0, 15*Sin[theta]}}, 1.25],
      Green,
      ClipPlanes -> InfinitePlane[{{0, 0, 10*Sin[theta]},
        {1, 0, 10*Sin[theta]}, {0, 1, 10*Sin[theta]}}]
    ]
  }, ViewPoint -> Front],
Control[{{theta, Pi/6}, Pi/6, Pi/4}]]

ClipPlanes

$\endgroup$
3
  • $\begingroup$ This doesn't seem to be working as shown in version 10.1.0; do you happen to know if it should? $\endgroup$
    – Mr.Wizard
    Jan 31, 2017 at 19:47
  • 1
    $\begingroup$ @Mr.Wizard ClipPlanes on version 10 was a bit shaky. The documentation reports that it was introduced in 10.0, but updated in version 11; I wonder if the problem you see might be related to its earlier unreliability. The code works well in my v.11. $\endgroup$
    – MarcoB
    Jan 31, 2017 at 20:04
  • 1
    $\begingroup$ @Mr.Wizard I think in v.10 you can cut Tubes only once. Here, we cut one Tube with one plane, and a second one with another and combine it in Graphics3D. Try this code in v.10: Graphics3D[{Tube[{{-2.5, 0, 0}, {0, 0, 0}, {15*Cos[theta], 0, 15*Sin[theta]}}, 1.25]}, ClipPlanes -> InfinitePlane[{{0, 0, 10*Sin[theta]}, {1, 0, 10*Sin[theta]}, {0, -1, 10*Sin[theta]}}]] It will probably work, but I think you won't be able to combine two cut tubes... $\endgroup$
    – mszynisz
    Jan 31, 2017 at 20:15

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .