Setup¶

In [1]:
from math import sqrt as sR
from math import acos as iC
from math import pi as pi
from random import random as RR

Constants & Functions¶

In [2]:
def getTriangleSides(xA, yA, xB, yB, xC, yC) :

    """
    Determine the sides of the triangle defined by 3 points.

    Parameters:
    xA, yA - Point.
    xB, yB - Point.  
    xC, yC - Point.     

    Returns:
    [d1, d2, d3] - Distances.
    """    

    A = sR((xC-xB)**2 + (yC-yB)**2) 
    B = sR((xC-xA)**2 + (yC-yA)**2)
    C = sR((xB-xA)**2 + (yB-yA)**2)

    return([A, B, C]) 


def lawOfCos(A, B, C) :
    
    """
    Determine the angles of the triangle defined by 3 sides.

    Parameters:
    A, B, C - Sides. 
    
    Returns:
    Angle.
    """   
    
    return(iC((B**2 + C**2 - A**2) / (2*B*C)))
      
def getTriangleAngles(A, B, C) :
    
    """
    Determine the angles of the triangle defined by 3 sides.

    Parameters:
    A, B, C - Sides. 
    
    Returns:
    [a, b, c] - Angles.
    """    

    a = lawOfCos(A, B, C)
    b = lawOfCos(B, C, A)
    c = lawOfCos(C, A, B)
    
    return([a, b, c])  
In [3]:
P = []
for i in range(10000000) :
    sAx = RR()
    sAy = RR()
    sBx = RR()
    sBy = RR()
    sCx = RR()
    sCy = RR()

    A, B, C = getTriangleSides(sAx, sAy, sBx, sBy, sCx, sCy)
    a, b, c = getTriangleAngles(A, B, C)
    p = (a+b)*(b+c)*(c+a) / (8*pi**3)
    P.append(p)
    
print(sum(P)/10000000)
0.027202657541858504

Fiddler¶

Rohan Lewis¶

2026.06.01¶