-
Notifications
You must be signed in to change notification settings - Fork 1
/
Element.py
28 lines (22 loc) · 841 Bytes
/
Element.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
import OpenGL.GLU as GLU
import math
import numpy as np
class Element:
screen_width = 1
screen_height = 1
def draw(self):
pass
def x_rot(self, ang, vect):
if ang == 0:
return vect
ang = float(ang)
rotx = np.array([[1, 0, 0, 0], [0, math.cos(ang / 180 * 3.14), -math.sin(ang / 180 * 3.14), 0],
[0, math.sin(ang / 180 * 3.14), math.cos(ang / 180 * 3.14), 0], [0, 0, 0, 1]])
return np.dot(rotx, vect)
def y_rot(self, ang, vect):
if ang == 0:
return vect
ang = float(ang)
roty = np.array([[math.cos(ang / 180 * 3.14), 0, math.sin(ang / 180 * 3.14), 0], [0, 1, 0, 0],
[-math.sin(ang / 180 * 3.14), 0, math.cos(ang / 180 * 3.14), 0], [0, 0, 0, 1]])
return np.dot(roty, vect)