I want to be able to define n
shapes and find the intersection between them and a line. I’m treating the shapes as “one” shape, i.e. I do not want any internal intersections (hence the volume equations).
I can do this by typing out each shape and equation as follows:
line = InfiniteLine[{{0.5, 0.5, 0.5}, {0.5, 0.5, 1}}]; (*shapes - I can define these*) shape1 = Ball[]; shape2 = Cone[{{0, 0, 0}, {1, 1, 1}}, 1/2]; (*------------ I want from here automated ---------*) (*surface equations *) surfaceequations1 = RegionMember[RegionBoundary[shape1], {x, y, z}]; surfaceequations2 = RegionMember[RegionBoundary[shape2], {x, y, z}]; volumeequation1 = RegionMember[shape1, {x, y, z}]; volumeequation2 = RegionMember[shape2, {x, y, z}]; intersection = NSolve[{x, y, z} \[Element] line && (surfaceequations1 || surfaceequations2) && ! (volumeequation1 && volumeequation2), {x, y, z}]; (* ---------- automation can stop here ---------- *) points = Point[{x, y, z}] /. intersection Graphics3D[{{Opacity[0.5], shape1}, {Opacity[0.7], shape2}, line, {Red, PointSize[0.015], points}}]
But this method means I have to type out each equation for each shape. If I change the number of shapes, I have to go through code and delete some.
The Problem
I want to be able to define n
shapes, then mathematica defines the n
surface equations, and the n
volume equations and puts them into NSolve
.
Also; apologies for the bad question title – I’m not sure what to call this problem.