Guest User

Untitled

a guest
Feb 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. NSolve[{x, y, z} [Element]
  2. line && (surfaceequations1 || surfaceequations2 ||
  3. surfaceequations3) && ! (volumeequation1 &&
  4. volumeequation2) && ! (volumeequation2 &&
  5. volumeequation3) && ! (volumeequation1 && volumeequation3), {x,
  6. y, z}]
  7.  
  8. constraints[shapes__] :=
  9. And[## & @@ (Not /@
  10. Through[(RegionMember[RegionIntersection@##] & @@@
  11. Subsets[{shapes}, {2}])@#]),
  12. RegionMember[RegionUnion @@ (RegionBoundary /@ {shapes})]@#] &
  13.  
  14.  
  15. intersections[l_, s__] :=
  16. NSolve[{x, y, z} [Element] l && constraints[s][{x, y, z}], {x, y,
  17. z}]
  18.  
  19. shape1 = Cuboid[{5, 5, 1}, {6, 25, 3}];
  20. shape2 = Cuboid[{6, 5, 1}, {21, 6, 3}];
  21. shape3 = Cuboid[{6, 24, 1}, {21, 25, 3}];
  22. shapes = {shape1, shape2, shape3};
  23. line = InfiniteLine[{{5.5, 10.5, 0.5}, {5.5, 10.5, 1}}];
  24. intersection = intersections[line, ##] & @@ shapes;
  25. intersection = DeleteDuplicates[intersection];
  26. points = {x, y, z} /. intersection;
  27. Graphics3D[{line, shapes, {Red, PointSize[0.05], Point[points]}}]
  28.  
  29. shape1 = Cuboid[{5, 5, 1}, {6, 25, 3}];
  30. shape2 = Cuboid[{6, 5, 1}, {21, 6, 3}];
  31. shape3 = Cuboid[{6, 24, 1}, {21, 25, 3}];
  32. shape4 = Cuboid[{6, 6, 1}, {13, 13, 3}];
  33. shape5 = Cuboid[{6, 17, 1}, {13, 24, 3}];
  34. shapes = {shape1, shape2, shape3, shape4, shape5};
  35. line = InfiniteLine[{{5.5, 10.5, 0.5}, {5.5, 10.5, 1}}];
  36. intersection = intersections[line, ##] & @@ shapes;
  37. intersection = DeleteDuplicates[intersection];
  38. points = {x, y, z} /. intersection;
  39. Graphics3D[{line, shapes, {Red, PointSize[0.05], Point[points]}}]
  40.  
  41. shape1 = Cuboid[{5, 5, 1}, {6, 25, 3}];
  42. shape2 = Cuboid[{6, 5, 1}, {21, 6, 3}];
  43. shape3 = Cuboid[{6, 24, 1}, {21, 25, 3}];
  44. shape4 = Cuboid[{6, 6, 1}, {13, 13, 3}];
  45. shape5 = Cuboid[{6, 17, 1}, {13, 24, 3}];
  46. shape6 = Cuboid[{14, 13, 1}, {15, 17, 3}];
  47. shape7 = Ellipsoid[{21, 9, 2}, {5, 4, 1}];
  48. shape8 = Cuboid[{16, 6, 1}, {21, 13, 3}];
  49. shape9 = Ellipsoid[{21, 21, 2}, {5, 4, 1}];
  50. shape10 = Cuboid[{16, 17, 1}, {21, 24, 3}];
  51. shape11 = Cuboid[{21, 9, 1}, {26, 10, 3}];
  52. shape12 = Cuboid[{21, 20, 1}, {26, 21, 3}];
  53. shape13 = Cuboid[{21, 10, 1}, {26, 13, 3}];
  54. shape14 = Cuboid[{21, 17, 1}, {26, 20, 3}];
  55. shape15 = Cuboid[{26, 11, 1}, {27, 13, 3}];
  56. shape16 = Cuboid[{27, 12, 1}, {28, 18, 3}];
  57. shape17 = Cuboid[{26, 17, 1}, {27, 19, 3}];
  58.  
  59. line = InfiniteLine[{{5.5, 10.5, 0.5}, {5.5, 10.5, 1}}];
  60.  
  61. shapes = {shape1, shape2, shape3, shape4, shape5, shape6, shape7,
  62. shape8, shape9, shape10, shape11, shape12, shape13, shape14,
  63. shape15, shape16, shape17};
  64.  
  65. intersection = intersections[line, ##] & @@ shapes;
  66. intersection = DeleteDuplicates[intersection]
  67. points = {x, y, z} /. intersection;
  68. Graphics3D[{line, shapes, {Red, PointSize[0.05], Point[points]}}]
Add Comment
Please, Sign In to add comment