4
$\begingroup$

I know I can obtain the Area of a Region, both numerically and symbolically, for example:

Area@Ellipsoid[{0,0},{a,b}]
(* a*b*Pi *)

How can I get the same for the RegionIntersection of two regions?

Let's say I have two regions

ClearAll[reg1,reg2];
reg1[h_, r_] := Cylinder[
    {
        {0,0,h/2},
        {0,0,-h/2}
    }
    , r
];
reg2[a_] := InfinitePlane[
    {0,0,0},
    {
        {0,1,0}, 
        {Cos[a], 0, Sin[a]}
    }
];


Animate[
    With[
        {
            h=2,
            r=1
        },
        Graphics3D[ {reg1[h,r], reg2[a]} ]
    ]//Evaluate
    ,{a, 0, Pi/4}
]

enter image description here

I would like to have an analytical symbolic expression for the intersection of these two regions and their area.

If I calculate it with specific values, I do get a reasonable output.

Assuming[
    And[
        0 < a < Pi/8,
        Element[h, PositiveReals]
        Element[r, PositiveReals]
    ],
    With[
        {
            a=Pi/16,
            h=100,
            r=1
        },
        Area[
            RegionIntersection[
                reg1[h, r],
                reg2[a]
            ]
        ]
    ]
]

enter image description here

But I get undefined otherwise:

Assuming[
    And[
        0 < a < Pi/8,
        Element[h, PositiveReals]
        Element[r, PositiveReals]
    ],
    With[
        {},
        Area[
            RegionIntersection[
                reg1[h, r],
                reg2[a]
            ]
        ]
    ]
]
(* Undefined*)

I'm using Wolfram Engine 14.0. Can't test on Wolfram Cloud because the computation exceeds the time limit for free accounts.

$Version
(* 14.0.0 for Microsoft Windows (64-bit) (December 21, 2023) *)

Am I missing a way to obtain symbolic expressions both for the region definition and its calculated quantities?

Is there a method to go from a Region to a symbolic condition, something like the inverse of ImplicitRegion, which goes from a condition to a Region?

$\endgroup$

2 Answers 2

3
$\begingroup$

Your code

Assuming[ And[0 < a < Pi/8,  Element[h, PositiveReals] Element[r, PositiveReals]], 
With[{}, Area[RegionIntersection[reg1[h, r], reg2[a]]]]]

works in 14.1 on Windows 10, resulting in

Piecewise[{{Pi*r^2*Sqrt[1 + Tan[a]^2], (h < 0 && Inequality[h/(2*r), Less, Tan[a], Less, -1/2*h/r]) || (h > 0 && Inequality[-1/2*h/r, Less, Tan[a], Less, h/(2*r)])}}, (r*Abs[h]*Cot[a]*(h*Sqrt[4 - (h^2*Cot[a]^2)/r^2] + 4*r*ArcCsc[(2*r*Tan[a])/h]*Tan[a])*Sqrt[1 + Tan[a]^2])/(2*h)]

Also, based on @azerbajdzan also in 13.0.1. This may be a bug in 14.0.

Addition. The code

reg = Assuming[
  And[
   0 < a < Pi/8, 
   Element[h, PositiveReals],
   Element[r, PositiveReals]
  ],
  RegionIntersection[reg1[h, r], reg2[a]]
 ];
 RegionConvert[reg, "Implicit"]

produces

ImplicitRegion[  r >= 0 && h != 0 &&    0 <= 1/2 - \[FormalZ]/h <= 1 && \[FormalX]^2 + \[FormalY]^2 <=     r^2 && \[FormalZ] == \[FormalX] Tan[      a], {\[FormalX], \[FormalY], \[FormalZ]}]

Unfortunately,

reg1 = RegionConvert[reg,     "Implicit"] /. {\[FormalX] -> x, \[FormalY] -> y, \[FormalZ] -> z,     h -> 1, r -> 1, a -> 3/10};RegionMember[reg1, {x, y, z}]

fails. The input

(x|y|z)\[Element]\DoubleStruckCapitalR]&&0<=1/2-z<=1&&x^2+y^2<=1&&z==x Tan[3/10]

is returned.

$\endgroup$
5
  • $\begingroup$ Thanks, can you get a symbolic expression for the region definition? $\endgroup$
    – rhermans
    Commented Aug 14 at 12:28
  • 1
    $\begingroup$ @rhemans: The code reg = Assuming[ And[0 < a < Pi/8, Element[h, PositiveReals] Element[r, PositiveReals]], RegionIntersection[reg1[h, r], reg2[a]]];RegionConvert[reg, "Implicit"] produces ImplicitRegion[ r >= 0 && h != 0 && 0 <= 1/2 - \[FormalZ]/h <= 1 && \[FormalX]^2 + \[FormalY]^2 <= r^2 && \[FormalZ] == \[FormalX] Tan[ a], {\[FormalX], \[FormalY], \[FormalZ]}]. $\endgroup$
    – user64494
    Commented Aug 14 at 12:37
  • $\begingroup$ Ok, I think I need to move to 14.1 . Thanks $\endgroup$
    – rhermans
    Commented Aug 14 at 12:38
  • 1
    $\begingroup$ Unfortunately, re1 = RegionConvert[reg, "Implicit"] /. {\[FormalX] -> x, \[FormalY] -> y, \[FormalZ] -> z, h -> 1, r -> 1, a -> 3/10};RegionMember[reg1, {x, y, z}] fails (The input is returned.). $\endgroup$
    – user64494
    Commented Aug 14 at 12:47
  • $\begingroup$ Good, I was missing RegionConvert and RegionMember, even if they fail in this example case. If you put that in your answer I will accept it, provided there is nothing more complete by then. $\endgroup$
    – rhermans
    Commented Aug 14 at 12:59
4
$\begingroup$

This outputs the result after quite some time.

reg1[h_, r_] := Cylinder[{{0, 0, h/2}, {0, 0, -h/2}}, r];
reg2[a_] := 
  InfinitePlane[{0, 0, 0}, {{0, 1, 0}, {Cos[a], 0, Sin[a]}}];

Assuming[{a, h, r} \[Element] Reals, 
 RegionIntersection[reg1[h, r], reg2[a]] // Area]

enter image description here

$\endgroup$
3
  • $\begingroup$ What version are you using? I have 14.0.0 for Microsoft Windows (64-bit) (December 21, 2023) (Wolfram Engine) and I get Undefined with your code, as well as with mine. $\endgroup$
    – rhermans
    Commented Aug 14 at 12:19
  • $\begingroup$ Version 13.0.1 and it took about 3 minutes. $\endgroup$ Commented Aug 14 at 12:50
  • $\begingroup$ Interesting, perhaps this is a 14.0 bug then. $\endgroup$
    – rhermans
    Commented Aug 14 at 12:55

Your Answer

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

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