4
$\begingroup$

I have a triangle that intersects with the sphere

enter image description here

How to count triangle area, which is in sphere?

If you have solution for polygon too, it's awesome.

$\endgroup$
  • $\begingroup$ Could you please provide some code with the above description. It would also be useful if you could give an example output you'd want to achieve :) $\endgroup$ – e.doroskevic Jan 12 '17 at 16:38
  • $\begingroup$ By basic common sense the intersection of a plane and a sphere is a circle so... couldn't you mathematically solve this by finding the circular intersection and then use mathematica for the rest? $\endgroup$ – user64742 Jan 13 '17 at 3:32
10
$\begingroup$

Let's take

ball = Ball[];
triangle = Triangle[{{0, 0, 0}, {2, 0, 0}, {2, 3, 1}}];
Graphics3D[{ball, triangle}, Axes -> True]

enter image description here

Then

reg = RegionIntersection[ball, triangle];
DiscretizeRegion[reg]

enter image description here

RegionDimension[reg]

2

RegionMeasure[reg]

$\frac{1}{4} \left(\pi -2 \sin ^{-1}\left(\sqrt{\frac{2}{7}}\right)\right)$

N@%

0.503427

Similarly for Polygons. The coordinates of neither the ball, nor the triangle (nor Polygon) need to be integers - all work just as well when they are real numbers (the RegionMeasure is a real number too).

| improve this answer | |
$\endgroup$
7
$\begingroup$

make a 2d projection to the plane of the triangle and use RegionIntersection.

triangle = Triangle[{{0, 0, 0}, {2, 0, 0}, {2, 3, 1}}];
ball = Ball[{1, 0, 0}, 1];
spherecenter = ball[[1]];
sphererad = ball[[2]];
pts = First@(List @@ triangle);
v1 = Normalize[pts[[2]] - pts[[1]]];
n = Normalize[Cross[v1, pts[[3]] - pts[[1]]]];
v2 = Cross[n, v1];
tri2d = Triangle[{v1, v2}.# & /@ (# - pts[[1]] & /@ pts)];
cc = {v1, v2}.(spherecenter - pts[[1]]);
d = sphererad^2 - ((spherecenter - pts[[1]]).n)^2;
r2d = If[d > 0, Sqrt[d], 0];
Area@RegionIntersection[tri2d, Disk[cc, r2d]]

1/28 (4 Sqrt[10] + 7 [Pi] + 14 ArcSin[3/7])

( notice I moved the ball center compared to corey979's example to make it a little more interesting )

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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