Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. Show[
  2. RegionPlot3D[x^2 + y^3 - z^2 > 0, {x, -2, 2}, {y, -2, 2}, {z, -2, 2},
  3. Boxed -> True, Axes -> True, BoxRatios -> Automatic],
  4. Graphics3D[Sphere[{0, -3, 0}], Boxed -> False, Axes -> False],
  5. PlotRange -> All]
  6.  
  7. ClearAll[tickF, axesF, boxF];
  8. tickF[div1_, div2_: - 1] := (If[div2 == -1,Thread[{#, #, {.02, 0}}, List, 2] &@
  9. FindDivisions[{#1, #2}, div1],
  10. Join @@ MapAt[Join @@ # &, {Thread[{#, #, {.02, 0}}, List, 2] &@#[[1]],
  11. Thread[{#, "", {.01, 0}}, List, 2] & /@ #[[2]]} &@
  12. FindDivisions[{#1, #2}, {div1, div2}], {2}]]) &;
  13.  
  14. axesF[div1_, div2_: - 1][gr_] := With[{pr = PlotRange[gr],
  15. ticks = tickF[div1, div2] @@@ PlotRange[gr],
  16. min = Transpose[PlotRange[gr]][[1]],
  17. max = Transpose[PlotRange[gr]][[2]]},
  18. Flatten@{{Text[#2, {1, 1.2, 1.} {#1 + #3[[1]], min[[2]], min[[3]]}],
  19. Line[1.05 {min, {max[[1]], min[[2]], min[[3]]}}],
  20. Line[1.05 {{#1 + #3[[1]], min[[2]], min[[3]]}, {#1 + #3[[1]],
  21. min[[2]] + If[#2 == "", .1, .2], min[[3]]}}]} & @@@ ticks[[1]],
  22. {Text[#2, {1., 1., 1.2} {min[[1]], #1 + #3[[1]], max[[3]]}],
  23. Line[1.05 {{min[[1]], min[[2]], max[[3]]}, {min[[1]], max[[2]], max[[3]]}}],
  24. Line[1.05 {{min[[1]], #1 + #3[[1]], max[[3]]}, {min[[1]], #1 + #3[[1]],
  25. max[[3]] - If[#2 == "", .1, .2]}}]} & @@@ ticks[[2]],
  26. {Text[#2, {1., 1.2, 1} {min[[1]], min[[2]], #1 + #3[[1]]}],
  27. Line[1.05 {min, {min[[1]], min[[2]], max[[3]]}}],
  28. Line[1.05 {{min[[1]], min[[2]], #1 + #3[[1]]}, {min[[1]],
  29. min[[2]] + If[#2 == "", .1, .2], #1 + #3[[1]]}}]} & @@@ ticks[[3]]}];
  30.  
  31. boxF[divs__][gr_] := Graphics3D[{axesF[divs][gr], gr[[1]],
  32. EdgeForm[{AbsoluteThickness[.2], GrayLevel[.4]}], FaceForm[],
  33. Cuboid @@ (1.05 Transpose[PlotRange[gr]])}, Boxed -> False];
  34.  
  35. Show[rp = RegionPlot3D[x^2 + y^3 - z^2 > 0, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}],
  36. Graphics3D[{Opacity[1], Sphere[{0, -3, 0}]}], boxF[5, 5][rp],
  37. Graphics3D[{CapForm["Butt"], Opacity[.7], Red,
  38. Tube[BezierCurve[{{2, -2, -2}, {3, -2, 0}, {5, 2, 0}, {3, 2, 0}}], .5]}],
  39. boxF[4]@Graphics3D[{CapForm["Butt"],
  40. Tube[BezierCurve[{{3, 3, 0}, {3, 2, 0}, {5, 5, 0}}], .5]}],
  41. PlotRange -> All, Axes -> False, BoxRatios -> Automatic,
  42. Boxed -> False, ImageSize -> 500]
  43.  
  44. Show[rp = RegionPlot3D[x^2 + y^3 - z^2 > 0, {x, -2, 2}, {y, -2, 2}, {z, -2, 2},
  45. Boxed -> True, Axes -> True, BaseStyle -> Opacity[.7], BoxRatios -> Automatic],
  46. Graphics3D[{Sphere[{0, -3, 0}], EdgeForm[{AbsoluteThickness[.2], GrayLevel[.4]}],
  47. FaceForm[], Cuboid @@ (1.05 Transpose[PlotRange[rp]])}],
  48. PlotRange -> All, Boxed -> False, PlotRangePadding -> 0]
  49.  
  50. Show[RegionPlot3D[
  51. x^2 + y^3 - z^2 > 0, {x, -2, 2}, {y, -2, 2}, {z, -2, 2},
  52. Boxed -> True, Axes -> True, BoxRatios -> Automatic], Graphics3D[
  53. Inset[
  54. Graphics[
  55. Inset[
  56. Graphics3D[Sphere[{0, 0, 0}],
  57. PlotRange -> {{-1, 1}, {-1, 10}, {-1, 1}}, Boxed -> False,
  58. Axes -> False], {0, 0}]], {0, -2, 0}]], PlotRange -> All]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement