2
$\begingroup$

Mathematica 13.1 for some reason gives an error for the following code:

FindInstance[{x, y, z} \[Element] ReflectionTransform[{0, 0, 1}][Cuboid[{-1/2, -1/2, 1/2}, {1/2, 1/2, 3/2}]], {x, y, z}] 

The problem as far as I can see is that ReflectionTransform[{0, 0, 1}][Cuboid[{-1/2, -1/2, 1/2}, {1/2, 1/2, 3/2}]] resolves as Cuboid[{-1/2,-1/2,-1/2},{1/2,1/2,-3/2}], which is a problem for FindInstance because the z coordinates are not in the correct order (it should output Cuboid[{-1/2,-1/2,-3/2},{1/2,1/2,-1/2}] instead).

('Strangely' enough, Graphics3D has no problem with this Cuboid with coordinates in the wrong order.)

Is this a bug? And how do I handle cases like these where Cuboids are incorrectly generated? I want to test whether or not two cubes (not necessarily axis-aligned) intersect using the code

intersectQ[cb1_?RegionQ, cb2_?RegionQ] := If[FindInstance[{x, y, z} \[Element] cb1 && {x, y, z} \[Element] cb2, {x, y, z}] == {}, False, True] 
$\endgroup$

1 Answer 1

4
$\begingroup$

RegionMember work.

reg = ReflectionTransform[{0, 0, 1}][ Cuboid[{-1/2, -1/2, 1/2}, {1/2, 1/2, 3/2}]]; pts = {x, y, z} /. FindInstance[RegionMember[reg]@{x, y, z}, {x, y, z}, 10] Graphics3D[{{Red, AbsolutePointSize[10], Point[pts]}, Opacity[.5], reg}, Boxed -> False] 

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.