forked from hashshura/algeo-transform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
85 lines (76 loc) · 4.33 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import os
import shape
import renderer
s = 0 # shape
r = 0 # renderer
dimension = ""
def showCmds():
if dimension == "2D":
print()
print(" Type \"exit\", \"stop\", or \"quit\" to quit the program")
print(" Type \"add x y\" to add a point to the graph")
print(" Type \"del\" to delete last inputted point")
print(" Type \"reset\" to reset any operations done after adding or deleting a point")
print()
print(" Type \"a\" or \"A\" to toggle on/off axes")
print()
print(" Type \"dilate v\" to scale the polygon (v = float)")
print(" Type \"shear p v\" to shear the polygon (p = x/y) (v = float)")
print(" Type \"stretch p v\" to stretch the polygon (p = x/y) (v = float)")
print(" Type \"reflect p\" to reflect the polygon (p = x/x=-y/etc)")
print(" Type \"translate dx dy\" to translate the polygon (dx,dy = float)")
print(" Type \"rotate r a b\" to rotate the polygon (r = float) (a,b = central point)")
print(" Type \"custom a b c d\" to execute custom transformation matrix (a,b,c,d is a 2x2 matrix)")
print()
else:
print()
print(" Type \"exit\", \"stop\", or \"quit\" to quit the program")
print(" Type \"reset\" to reset any operations done after adding or deleting a point")
print(" Type \"a\" or \"A\" to toggle on/off axes")
print()
print(" Type \"dilate v\" to scale the polygon (v = float)")
print(" Type \"shear p v\" to shear the polygon (p = x/y/z) (v = float)")
print(" Type \"stretch p v\" to stretch the polygon (p = x/y/z) (v = float)")
print(" Type \"reflect p\" to reflect the polygon (p = x/x=-y/etc)")
print(" Type \"translate dx dy dz\" to translate the polygon (dx,dy,dz = float)")
print(" Type \"rotate r p a b c\" to rotate the polygon (r = float) (p = x/y/z) (a,b,c = central point)")
print(" Type \"custom a b c d e f g h i\" to execute custom transformation matrix (a-i is a 3x3 matrix")
print()
print(" Press arrow keys to rotate the camera")
print(" Press PageUp to Zoom Out")
print(" Press PageDown to Zoom In")
print()
print("Make sure that your mouse pointer focus is on the GLUT window.")
print("Type any command below:")
print(">> ",end='',flush=True)
def welcomeScreen():
global s, dimension
os.system('cls')
print("________________/\\\\\\________________/\\\\\\\\\\\\_____/\\\\\\\\\\\\_________________________________ ")
print(" _______________\\/\\\\\\_______________\\////\\\\\\____\\////\\\\\\_________________________________ ")
print(" _______________\\/\\\\\\__________/\\\\\\____\\/\\\\\\_______\\/\\\\\\_________________________________ ")
print(" _____/\\\\\\\\\\\\\\\\_\\/\\\\\\_________\\///_____\\/\\\\\\_______\\/\\\\\\_____/\\\\\\\\\\\\\\\\\\_____/\\\\\\____/\\\\\\_ ")
print(" ___/\\\\\\//////__\\/\\\\\\\\\\\\\\\\\\\\___/\\\\\\____\\/\\\\\\_______\\/\\\\\\____\\////////\\\\\\___\\///\\\\\\/\\\\\\/__ ")
print(" __/\\\\\\_________\\/\\\\\\/////\\\\\\_\\/\\\\\\____\\/\\\\\\_______\\/\\\\\\______/\\\\\\\\\\\\\\\\\\\\____\\///\\\\\\/____ ")
print(" _\\//\\\\\\________\\/\\\\\\___\\/\\\\\\_\\/\\\\\\____\\/\\\\\\_______\\/\\\\\\_____/\\\\\\/////\\\\\\_____/\\\\\\/\\\\\\___ ")
print(" __\\///\\\\\\\\\\\\\\\\_\\/\\\\\\___\\/\\\\\\_\\/\\\\\\__/\\\\\\\\\\\\\\\\\\__/\\\\\\\\\\\\\\\\\\_\\//\\\\\\\\\\\\\\\\/\\\\__/\\\\\\/\\///\\\\\\_ ")
print(" ____\\////////__\\///____\\///__\\///__\\/////////__\\/////////___\\////////\\//__\\///____\\///__")
print()
print("\t\t\t Welcome to the our lovely solution to")
print("\t\t\t IF2123 Geometric Algebra's 2nd Big Mission")
print()
dimension = input('Please choose between "2D" or "3D": ')
while ((dimension != "3D") and (dimension != "2D")):
dimension = input('Please enter valid input ("2D" or "3D"): ')
else:
print("Your input is " + dimension)
if (dimension == "3D"):
s.points = [[100,100,100],[100,100,-100],[100,-100,100],[100,-100,-100],[-100,100,100],[-100,100,-100],[-100,-100,100],[-100,-100,-100]]
s.points_backup = s.points[:]
s.points_before = s.points[:]
# MAIN
s = shape.Shape()
welcomeScreen()
showCmds()
renderer = renderer.Renderer(s, dimension)
renderer.render()