# Triangle area in sphere

I have a triangle that intersects with the sphere

How to count triangle area, which is in sphere?

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

• 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 :) Jan 12, 2017 at 16:38
• 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? Jan 13, 2017 at 3:32

## 2 Answers

Let's take

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


Then

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


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).

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 )