2
$\begingroup$

I can generate the intersection of a line and a cone (from the example in the documentation). Is there a simple way to do the same for a line and an elliptical cone?

i.e., this works:

r1 = InfiniteLine[{{-1, -2, -3}, {1, 2, 3}}];
r2 = Cone[{{0, 0, 2.}, {0, 0, -4}}, 1];
r3 = RegionIntersection[r1,r2]

Line[{{-0.243659, -0.487317, -0.730976}, {0.38401, 0.768019, 1.15203}}]

Graphics3D[{Opacity[0.5], {Red, r1}, {Green, r2}, {Blue, r3}}]

enter image description here

And I can make an elliptical cone using scale:

r4 = Scale[Cone[{{0, 0, 2.}, {0, 0, -4}}, 1], {2, 4, 3}, {0, 0, 0}]; 

Elliptical cone

But r4 has head "Scale" rather than a Region. So RegionIntersection isn't happy:

RegionIntersection[r1,r4]
RegionIntersection::reg: Scale[Cone[{{0,0,2.},{0,0,-4}},1],{2,4,3},{0,0,0}] is not a correctly specified region. >>

Is there a way to convert r4 to a correctly specified region or does RegionIntersection work for specific shapes only?

$\endgroup$

1 Answer 1

3
$\begingroup$

You can use ScalingTransform instead of Scale:

r4 = TransformedRegion[
 Cone[{{0, 0, 2.}, {0, 0, -4}}, 1], 
 ScalingTransform[{2, 4, 3}]
]

However, this isn't a Region object but a TransformedRegion. In my experience, Mathematica's region support is patchy and regularly doesn't work as expected - for instance, the TransformedRegion docs themselves are either incomplete or wrong, in the Scope/Derived Regions example, input line 3.

DiscretizeRegion fails to discretize r4 as stated, though it can discretize the intersection with the line, and it manages on r4 if you use exact 2 instead of 2. in the definition of the cone. Graphics3D fails with all of them. You can still use RegionMeasure, Area, Volume etc with them, though.

This may be related to this bug.

$\endgroup$
1
  • 1
    $\begingroup$ Great! Thanks Patrick, then I can use : dr = DiscretizeRegion[RegionIntersection[r1, r4]] and then MeshCoordiates[ dr][[-1]] and [[-2]] appear to be the two end points (although I'm not sure if this will always be the case). Giving : Show[dr, Graphics3D[{Opacity[0.3], {Red, r4}}], Graphics3D[{PointSize[Large], Green, Point[{Last[MeshCoordinates@dr], MeshCoordinates[dr][[-2]]}]}], ImageSize -> 200] (I can't figure out the formatting in this comment. Sorry!) $\endgroup$
    – DrBubbles
    Sep 8, 2015 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.