Advertisement
Matthen

Double Bubble

Apr 16th, 2013
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. Manipulate[
  2. With[{d = Sqrt[1 + r2^2 - 2 r2 Cos[\[Pi]/3]], R = 1/(1/r2 - 1)^2},
  3. With[{y2 = Sqrt[(4 d^2 - (d^2 - r2^2 + 1)^2)/(4 d^2)],
  4. x2 = (d^2 - r2^2 + 1)/(2 d)}, Show[{
  5. ContourPlot3D[x^2 + y^2 + z^2 == 1,
  6. {x, -1.2, 3.}, {y, -2.1, 2.1}, {z, -2.1, 2.1},
  7. RegionFunction ->
  8. Function[{x, y, z}, (x - d)^2 + y^2 + z^2 >= r2^2],
  9. ColorFunction ->
  10. Function[{x, y, z, f},
  11. Directive[Opacity[0.4], ColorData["LakeColors"][0.5 + z/2]]],
  12. Mesh -> 2, Boxed -> False, Axes -> None
  13. ],
  14. ContourPlot3D[(x - d)^2 + y^2 + z^2 == r2^2,
  15. {x, d - 1, d + 1}, {y, -1, 1}, {z, -1, 1},
  16. RegionFunction -> Function[{x, y, z},
  17. x^2 + y^2 + z^2 >= 1
  18. ],
  19. ColorFunction ->
  20. Function[{x, y, z, f},
  21. Directive[Opacity[0.4], ColorData["Aquamarine"][0.5 + y/2]]],
  22. Mesh -> 2],
  23. ContourPlot3D[(x - x2 - Sqrt[R - y2^2])^2 + y^2 + z^2 == R,
  24. {x, x2 + Sqrt[R - y2^2] - R^2,
  25. x2 + Sqrt[R - y2^2] + R^2}, {y, -1, 1}, {z, -1, 1},
  26. RegionFunction -> Function[{x, y, z},
  27. x^2 + y^2 + z^2 <= 1 && (x - d)^2 + y^2 + z^2 <= r2^2
  28. ],
  29. ColorFunction ->
  30. Function[{x, y, z, f}, Directive[Opacity[1.0], Gray]], Mesh -> 2
  31. ]
  32. }, ImageSize -> 500]]], {{r2, .53,
  33. "\!\(\*SubscriptBox[\(r\), \(B\)]\)"}, .25, .95}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement