# How to apply geometric transformation and do test for region intersection

## Description

I want to generate a number of ellipses, rotate each ellipse using random angle, and then test each ellipse if it intersects with any other regions within arbitrary geometry.

I can create my ellipses, and rotate each ellipse using random angle. However, the methods I use don't seem to be compatible when used inside RegionIntersection

How could I generate, rotate and test the rotated ellipses to check for intersections with other members of the geometric composition?

## Code

Module[
{data,r1, r2},
(*Variable declaration*)
data = RandomInteger[{1,100},{100,2}];

(*Program*)
(*Visual Representation*)
Show[
Graphics @ {FaceForm @ None, EdgeForm @ Red,r1[data[[1]],2.5,Pi/6]},
Graphics @ {FaceForm @ None, EdgeForm @ Blue,r2[data[[1]],2.5,Pi/4]},
Graphics @ {Opacity @ .5,FaceForm @ Gray, Disk[data[[1]],1]},
Axis-> True,
Frame-> True
]
]


Following are the lines which would crash my code due to ,what I suspect, argument incompatibility

(*Intersection [Fail]*)
RegionIntersection[r1,Disk[data[[1]],1]],
RegionIntersection[r2,Disk[data[[1]],1]]

• – Carl Woll Feb 16 '17 at 1:25
• @CarlWoll, thank you for your reply. I think the method works. I am happy to accept it as an answer if you'd like to post one below? – e.doroskevic Feb 16 '17 at 10:31

The problem is that GeometricTransformation doesn't produce an object that is RegionQ:

GeometricTransformation[
Disk[{0, 0}, {1, 2}],
RotationTransform[Pi/2, {0, 0}]
] //RegionQ


False

Instead of GeometricTransformation, you should use TransformedRegion:

r1 = TransformedRegion[
Disk[{0, 0}, {1, 2}],
RotationTransform[Pi/2, {0, 0}]
];
r1 //RegionQ


True

Using RegionIntersection with r1:

int = RegionIntersection[r1, Disk[{1, 1}, 1]];
DiscretizeRegion[int]
RegionMeasure[int]//N


1.20138

• Yeah I figured it doesn't return True when tested with RegionQ hence the incompatibility error. I was unaware of TransformedRegion function. Thank you for providing an answer to my question. I learned something new :) (y) – e.doroskevic Feb 16 '17 at 17:06
• But this is all a little broken. GeometricTransformation can (and should, where possible) produce RegionQ objects. For example, Normal@GeometricTransformation[Cylinder[], ScalingTransform[{2, 2, 2}]]. But this does not work properly in 2D (reported bug). – TheDoctor Aug 14 '17 at 4:24