-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathessential.py
99 lines (77 loc) · 2.69 KB
/
essential.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
96
97
98
99
#This file contains all the essential methods for the
#illustrative example
#It only contains the basic implementations of pydy-viz
#also it doesnot check for TypeErrors etc.
class MeshShape(object):
def __init__(self,name,point_list,color='grey',origin=[0,0,0]):
self._name = name
self._points = point_list
self._color = color
self._origin = origin
@property
def name(self):
return self._name
@name.setter
def name(self,new_name):
self._name = new_name
@property
def points(self):
return self._points
@points.setter
def points(self,new_point_list):
self._points = new_point_list
@property
def color(self):
return self._color
@color.setter
def color(self,new_color):
self._color = new_color
@property
def origin(self):
return self._origin
@color.setter
def origin(self,new_origin):
self._origin = new_origin
class VisualizationFrame(object):
def __init__(self,name,rigidbody,shape=None):
#It is only to be used for rigidbody here, as per the
#specific requirements of the illustrative example
self._name = name
self._reference_frame = rigidbody.get_frame()
self._point = rigidbody.get_masscenter()
self._shape = shape
self._transformation_matrix = \
[[1, 0, 0, 0], \
[0, 1, 0, 0], \
[0, 0, 1, 0], \
[0, 0, 0, 1]]
def homogeneous_transformation(self,rframe):
rotation_matrix = self._reference_frame.dcm(rframe)
for i in range(0,3):
for j in range(0,3):
self._transformation_matrix[i][j] = rotation_matrix
return self._transformation_matrix
def add_simulation_data(self,file_name=None):
#TODO
pass
def generate_json():
#TODO
pass
class Scene():
def __init__(self,name,reference_frame,origin,height=800,width=800):
self._name = name
self._reference_frame=reference_frame
self._origin = origin #contains point
self._child_vframes = []
self._height = height
self._width = width
@property
def vframes(self):
return self._child_vframes
@vframes.setter
def vframes(self,vframes):
for vframe in vframes:
self._child_vframes.append(vframe)
def generate_json(self):
#TODO
pass