Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy
- import math
- phiList = []
- AB_list = []
- BC_list = []
- CD_list = []
- DE_list = []
- EA_list = []
- B_vert = []
- C_vert = []
- D_vert = []
- BC_Verts = []
- BCD_Verts = []
- '''
- This program seeks to find a set of x,y coordinates for 5 points that are exactly
- the same angle apart from one another as those 5 dots found throughout the
- Liber Primus.
- '''
- def gcd(a, b):
- if a == 0:
- return b
- return gcd(b % a, a)
- def phi(n):
- '''
- This is some copy and pasted code on how to find the totient of the argument.
- '''
- result = 1
- for i in range(2, n):
- if gcd(i, n) == 1:
- result += 1
- return result
- for n in range(0, 100):
- '''
- This loop will create a list of tuples of the x and y coordinates of the graph of the totient fucntion. I add 1 to n here since the range starts at zero. I know
- there are easy fixes to this, but it works and is still pretty apparent what is happening.
- '''
- phiList.append((n + 1, phi(n + 1)))
- for i in range(len(phiList)):
- '''
- This is where things get a little bit trickier, but are still pretty simple.
- I create a loop that iterates through each point, and then nest a second loop
- that compares every point to each other. It then uses some numpy/math functions
- to find the slope of each set of points in relation to the origin and from there
- measure their angles.
- I used photoshop to figure out the angles of each of the Liber Primus points,
- which means that there was some margin of error that I tried to account for.
- That is why the 'deg' variable is compared between some angle measures. This
- might cause some issues.
- This loop will then organize all of the lines that we compared based on their
- angle measure. I denoted each of the points from the Liber Primus from left to
- right, as A, B, C, D, and E, and the lines between them as AB, BC, CD, DE, and EA.
- '''
- for x in range(len(phiList)):
- tempTup = tuple(numpy.subtract(phiList[i], phiList[x]))
- deg = math.degrees(math.atan2(tempTup[1], tempTup[0]))
- if deg > float(-76) and deg < float(-73):
- AB_list.append(list(phiList[i]))
- AB_list.append(list(phiList[x]))
- elif deg > float(53) and deg < float(56):
- BC_list.append(list(phiList[i]))
- BC_list.append(list(phiList[x]))
- elif deg > float(-46) and deg < float(-43):
- CD_list.append(list(phiList[i]))
- CD_list.append(list(phiList[x]))
- elif deg > float(15) and deg < float(19):
- DE_list.append(list(phiList[i]))
- DE_list.append(list(phiList[x]))
- elif deg > float(-14) and deg < float(-12):
- EA_list.append(list(phiList[x]))
- EA_list.append(list(phiList[i]))
- for i in range(len(AB_list)):
- '''
- After we have all of the lines of the totient function organized,
- this loop will find all lines that have a vertex B that connects a line from
- AB and BC.
- Because we are looking for the B vertex, it only looks at every even element from
- the AB_list(since it is organized in such a way that every odd entry is the
- x,y coordinates for an A point, and the even entries are all B points.
- For every vertext found, it will add The A, B, and C points of said vertex into
- a new list to build upon later.
- '''
- if i%2 == 0:
- if AB_list[i] in BC_list[1::2]:
- B_vert.append([AB_list[i - 1], AB_list[i], BC_list[BC_list.index(AB_list[i]) + 1]])
- print('B_vert Complete')
- for i in range(len(BC_list)):
- '''
- Same shit as above but for a C-vertext between lines BC and CD
- '''
- if i%2 == 0:
- if BC_list[i] in CD_list[1::2]:
- C_vert.append([BC_list[i - 1], BC_list[i], CD_list[CD_list.index(BC_list[i]) + 1]])
- print('C_vert complete')
- for i in range(len(CD_list)):
- '''
- ^
- '''
- if i%2 == 0:
- if CD_list[i] in DE_list[1::2]:
- D_vert.append([CD_list[i - 1], CD_list[i], DE_list[DE_list.index(CD_list[i]) + 1]])
- print('D_vert complete')
- for i in range(len(B_vert)):
- '''
- This does a pretty similar thing to the loops above.
- It iterates through the list of B-vertices and looks at their BC line portion,
- and then compares them to the C-vertices BC lines. If they share that BC line,
- then we smash them together to make a BC vertex, which should hopefully
- look like the first foour points of the image in the Liber Primus.
- Threw in some print statements because this program does take a really long time,
- and it is nice to see where you're at while it is running.
- '''
- for x in range(len(C_vert)):
- if B_vert[i][1:2] == C_vert[x][0:1]:
- BC_Verts.append([B_vert[i][0], B_vert[i][1], B_vert[i][2], C_vert[x][2]])
- print('BC_Verts complete')
- print('length of BC_Verts: ' + str(len(BC_Verts)))
- for i in range(len(BC_Verts)):
- '''
- This will do the same as above, but this time comparing the CD line from each
- entry in BC_Verts to the CD line of each D-vertex. If successful, it will
- give us every set of points in the totient function that have the same angle
- measures from point to point.
- This isn't perfect, and will require a human to go through and verify that the angle
- measures create the same shape(since just having same angle measures does not mean it will
- be the same shape, e.g. squares and rectangles), but it will hopefully reduce
- the amount of human work required here. It could also get coded out by comparing the
- length of lines to one another(but since we don't know how long each line would be,
- the comparisons would have to be something like 'line AB is 1.3x longer than line BC'
- '''
- for x in range(len(D_vert)):
- if BC_Verts[i][2:3] == D_vert[x][0:1]:
- BCD_Verts.append([BC_Verts[i][0], BC_Verts[i][1], BC_Verts[i][2], BC_Verts[i][3], D_vert[x][2]])
- print(BCD_Verts)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement