-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquadmap.py
95 lines (77 loc) · 3.19 KB
/
quadmap.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
86
87
88
89
90
91
92
93
94
95
from math import *
import numpy as np
class Quadrilateral:
@staticmethod
def map2D(): #angle is in radians
point1=np.array([1, 1, 0, 0])
point2=np.array([-1, 1, 0, 0])
point3=np.array([-1, -1, 0, 0])
point4=np.array([1, -1, 0, 0])
return point1, point2, point3, point4
@staticmethod
def __multiplyMatricies(point1, point2, point3, point4, matrix):
return np.matmul(matrix, point1), np.matmul(matrix, point2), np.matmul(matrix, point3), np.matmul(matrix, point4)
@staticmethod
def __zwRotation(angle, point1, point2, point3, point4):
zwAxisRotation=np.array([
[cos(angle), -sin(angle), 0, 0],
[sin(angle), cos(angle), 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]
])
return Quadrilateral.__multiplyMatricies(point1, point2, point3, point4, zwAxisRotation)
@staticmethod
def __ywRotation(angle, point1, point2, point3, point4):
ywAxisRotation=np.array([
[cos(angle), 0, -sin(angle), 0],
[0, 1, 0, 0],
[sin(angle), 0, cos(angle), 0],
[0, 0, 0, 1]
])
return Quadrilateral.__multiplyMatricies(point1, point2, point3, point4, ywAxisRotation)
@staticmethod
def __yzRotation(angle, point1, point2, point3, point4):
yzAxisRotation=np.array([
[cos(angle), 0, 0, -sin(angle)],
[0, 1, 0, 0],
[0, 0, 1, 0],
[sin(angle), 0, 0, cos(angle)]
])
return Quadrilateral.__multiplyMatricies(point1, point2, point3, point4, yzAxisRotation)
@staticmethod
def __xwRotation(angle, point1, point2, point3, point4):
xwAxisRotation=np.array([
[1, 0, 0, 0],
[0, cos(angle), -sin(angle), 0],
[0, sin(angle), cos(angle), 0],
[0, 0, 0, 1]
])
return Quadrilateral.__multiplyMatricies(point1, point2, point3, point4, xwAxisRotation)
@staticmethod
def __xzRotation(angle, point1, point2, point3, point4):
xzAxisRotation=np.array([
[1, 0, 0, 0],
[0, cos(angle), 0, -sin(angle)],
[0, 0, 1, 0],
[0, sin(angle), 0, cos(angle)]
])
return Quadrilateral.__multiplyMatricies(point1, point2, point3, point4, xzAxisRotation)
@staticmethod
def __xyRotation(angle, point1, point2, point3, point4):
xyAxisRotation=np.array([
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, cos(angle), -sin(angle)],
[0, 0, sin(angle), cos(angle)]
])
return Quadrilateral.__multiplyMatricies(point1, point2, point3, point4, xyAxisRotation)
@staticmethod
def combineRotation(angleList):
A, B, C, D=Quadrilateral.map2D()
A, B, C, D=Quadrilateral.__zwRotation(angleList[0], A, B, C, D)
A, B, C, D=Quadrilateral.__ywRotation(angleList[1], A, B, C, D)
A, B, C, D=Quadrilateral.__yzRotation(angleList[2], A, B, C, D)
A, B, C, D=Quadrilateral.__xwRotation(angleList[3], A, B, C, D)
A, B, C, D=Quadrilateral.__xzRotation(angleList[4], A, B, C, D)
A, B, C, D=Quadrilateral.__xyRotation(angleList[5], A, B, C, D)
return A, B, C, D