An astounding alignment occurs 2048/5/28 with the inner 5 planets having heliocentric longitudes (in degrees): 248.229, 66.631, 246.967, 249.605, 67.684.
The planets are at most 0.875 degrees from the line (through Sol) with slope 67.823 degrees. In this case, the method sought (PA) would give: PA(248.229, 66.631, 246.967, 249.605, 67.684) = (67.823, 0.875)
I have tried two simple algorithms which both fail on the case: 2003/9/9: 340.256, 180.320, 346.156, 342.316, 150.285
One method gives slope=127.867, deviation=51.019 and the other 271.867, 85.251. I think a correct method would give s=163.466, d=7.515.
The main problem is that planets on opposite sides of Sol can be (nearly) on the same line.
Python or javascript appreciated. Yay I figured out how to edit! Or not.
def score3(wList):
wSize = len(wList)
#print wList
first = wList[0]
d1 = first - 90.0
if d1 < 0.0: d1 += 360.0
d2 = first + 90.0
if d2 > 360.0: d1 -= 360.0
if d1 > d2: d1,d2 = d2,d1
sum = 0.0
for wx in range(0,wSize):
curr = wList[wx]
if (curr > d1) and (curr < d2):
new = curr
else:
new = (curr + 180.0) % 360.0
wList[wx] = new
sum += new
#print '%7.3f --> %7.3f' % (curr, new)
avg = sum / wSize
#print avg, wList
score = 0.0
for wx in range(0,wSize):
curr = wList[wx]
diff = curr - avg
if diff < 0: diff = - diff
score += diff
score /= wSize
return avg, score