#Get a random point on sandwich edge.
def getPoint() :
#Randomly select x or y axis.
s = RC(("x","y"))
#Randomly select corresponding left/right or down/up.
v = RC((0, 1))
if s == "x":
x = v
y = RR()
else:
x = RR()
y = v
return((x, y))
#Get the smaller sandwich piece's area.
def getSmallerArea(p) :
x_0 = RR()
y_0 = 0
x_1 = p[0]
y_1 = p[1]
#1/4 of points will be on the same side. Still one square. A = 0.
if y_1 == 0 :
A = 0
#1/2 of points will be on adjacent sides. One triangle, one pentagon, determine area of triangle (always smaller).
elif x_1 == 0 or x_1 == 1 :
if x_1 == 0 :
A = x_0 * y_1 / 2
else :
A = (1-x_0) * y_1 / 2
#1/4 of points will be on opposite sides. Two trapezoids. determine which one is smaller.
else : #y_1 == 1
#Left trapezoid
a_left = (x_0 + x_1) / 2
#Right trapezoid
a_right = ((1-x_0) + (1-x_1)) / 2
if a_left < a_right :
A = a_left
else :
A = a_right
return(A)