# 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 :) – e.doroskevic Jan 12 '17 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? – user64742 Jan 13 '17 at 3:32

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


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

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