Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSolve[{x, y, z} [Element]
- line && (surfaceequations1 || surfaceequations2 ||
- surfaceequations3) && ! (volumeequation1 &&
- volumeequation2) && ! (volumeequation2 &&
- volumeequation3) && ! (volumeequation1 && volumeequation3), {x,
- y, z}]
- constraints[shapes__] :=
- And[## & @@ (Not /@
- Through[(RegionMember[RegionIntersection@##] & @@@
- Subsets[{shapes}, {2}])@#]),
- RegionMember[RegionUnion @@ (RegionBoundary /@ {shapes})]@#] &
- intersections[l_, s__] :=
- NSolve[{x, y, z} [Element] l && constraints[s][{x, y, z}], {x, y,
- z}]
- shape1 = Cuboid[{5, 5, 1}, {6, 25, 3}];
- shape2 = Cuboid[{6, 5, 1}, {21, 6, 3}];
- shape3 = Cuboid[{6, 24, 1}, {21, 25, 3}];
- shapes = {shape1, shape2, shape3};
- line = InfiniteLine[{{5.5, 10.5, 0.5}, {5.5, 10.5, 1}}];
- intersection = intersections[line, ##] & @@ shapes;
- intersection = DeleteDuplicates[intersection];
- points = {x, y, z} /. intersection;
- Graphics3D[{line, shapes, {Red, PointSize[0.05], Point[points]}}]
- shape1 = Cuboid[{5, 5, 1}, {6, 25, 3}];
- shape2 = Cuboid[{6, 5, 1}, {21, 6, 3}];
- shape3 = Cuboid[{6, 24, 1}, {21, 25, 3}];
- shape4 = Cuboid[{6, 6, 1}, {13, 13, 3}];
- shape5 = Cuboid[{6, 17, 1}, {13, 24, 3}];
- shapes = {shape1, shape2, shape3, shape4, shape5};
- line = InfiniteLine[{{5.5, 10.5, 0.5}, {5.5, 10.5, 1}}];
- intersection = intersections[line, ##] & @@ shapes;
- intersection = DeleteDuplicates[intersection];
- points = {x, y, z} /. intersection;
- Graphics3D[{line, shapes, {Red, PointSize[0.05], Point[points]}}]
- shape1 = Cuboid[{5, 5, 1}, {6, 25, 3}];
- shape2 = Cuboid[{6, 5, 1}, {21, 6, 3}];
- shape3 = Cuboid[{6, 24, 1}, {21, 25, 3}];
- shape4 = Cuboid[{6, 6, 1}, {13, 13, 3}];
- shape5 = Cuboid[{6, 17, 1}, {13, 24, 3}];
- shape6 = Cuboid[{14, 13, 1}, {15, 17, 3}];
- shape7 = Ellipsoid[{21, 9, 2}, {5, 4, 1}];
- shape8 = Cuboid[{16, 6, 1}, {21, 13, 3}];
- shape9 = Ellipsoid[{21, 21, 2}, {5, 4, 1}];
- shape10 = Cuboid[{16, 17, 1}, {21, 24, 3}];
- shape11 = Cuboid[{21, 9, 1}, {26, 10, 3}];
- shape12 = Cuboid[{21, 20, 1}, {26, 21, 3}];
- shape13 = Cuboid[{21, 10, 1}, {26, 13, 3}];
- shape14 = Cuboid[{21, 17, 1}, {26, 20, 3}];
- shape15 = Cuboid[{26, 11, 1}, {27, 13, 3}];
- shape16 = Cuboid[{27, 12, 1}, {28, 18, 3}];
- shape17 = Cuboid[{26, 17, 1}, {27, 19, 3}];
- line = InfiniteLine[{{5.5, 10.5, 0.5}, {5.5, 10.5, 1}}];
- shapes = {shape1, shape2, shape3, shape4, shape5, shape6, shape7,
- shape8, shape9, shape10, shape11, shape12, shape13, shape14,
- shape15, shape16, shape17};
- intersection = intersections[line, ##] & @@ shapes;
- intersection = DeleteDuplicates[intersection]
- points = {x, y, z} /. intersection;
- Graphics3D[{line, shapes, {Red, PointSize[0.05], Point[points]}}]
Add Comment
Please, Sign In to add comment