Anonymous
public text v1 · immutable#The following code attempts to use a line
#(defined by x0, y0 and x1, y1) to find the slice
#of a 16-piece pie (slice_num) that
#the point lands on.
import math
#these values could be anything
#(positive or negative) but they
#are always integers
x0 = 1
y0 = 1
x1 = 5
y1 = 5
x = math.cos((x1- x0) / math.sqrt((x1 - x0)^2 + (y1 - y0)^2) / (math.pi / 8))
if x1 > 0 and y1 < 0:
x += 16
elif x1 < 0 and y1 < 0:
x += 4
slice_num = int(round(x, 0))