-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrusselements.py
152 lines (108 loc) · 4.25 KB
/
trusselements.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import math
class Joint:
def __init__(self, name, x, y):
assert type(x) == float or type(x) == int , "x coordinate has to be a float"
assert type(y) == float or type(x) == int, "y coordinate has to be a float"
self.x = x
self.y = y
self.name = name
def __str__(self):
return self.name
class Member:
def __init__(self, joint1, joint2):
assert type(joint1) == Joint and type(joint2) == Joint , "You have to give to Joints"
self.joint1 = joint1
self.joint2 = joint2
def isconnected(self, joint):
assert type(joint) == Joint ,'the tested join has to be type Joint'
if self.joint1 == joint:
self.otherjoint = self.joint2
return True
elif self.joint2 == joint:
self.otherjoint = self.joint1
return True
else: return False
def angle(self, joint):
assert type(joint) == Joint , "joint has to be type Joint"
anglevar = math.atan2(self.otherjoint.y - joint.y, self.otherjoint.x - joint.x)
return anglevar
def giveload(self, load):
self.load = load
def reset(self):
self.load = None
self.otherjoint = None
class Load:
def __init__(self, joint, value, angle):
assert type(joint) == Joint ,'first argument has to be a joint'
self.joint = joint
self.value = value
self.angle = angle
self.xcoef = None
self.ycoef = None
def getxcoef(self):
assert self.value != None ,"the value of the support has to ve found in order to calculate the coeficients"
if self.xcoef == None:
self.xcoef =(self.value * math.cos(math.radians(self.angle)))
return self.xcoef
else: return self.xcoef
def getycoef(self):
assert self.value != None ,"the value of the support has to ve found in order to calculate the coeficients"
if self.ycoef == None:
self.ycoef = (self.value * math.sin(math.radians(self.angle)))
return self.ycoef
else: return self.ycoef
class RollerSupport:
def __init__(self, joint, angle):
assert type(joint) == Joint, 'first argument has to be a joint'
self.joint = joint
self.angle = angle
self.id = 1
self.value = None
self.xcoef = None
self.ycoef = None
def givevalue(self, value):
self.value = value
def isconnected(self, joint):
if self.joint == joint:
return True
else: return False
def getxcoef(self):
assert self.value != None ,"the value of the support has to ve found in order to calculate the coeficients"
if self.xcoef == None:
self.xcoef =(self.value * math.cos(math.radians(self.angle)))
return self.xcoef
else: return self.xcoef
def getycoef(self):
assert self.value != None ,"the value of the support has to ve found in order to calculate the coeficients"
if self.ycoef == None:
self.ycoef = self.value * math.sin(math.radians(self.angle))
return self.ycoef
else: return self.ycoef
def reset(self):
self.value = None
self.xcoef = None
self.ycoef = None
class PinnedSuppport(RollerSupport):
def __init__(self, joint):
assert type(joint) == Joint ,'first argument has to be a joint'
self.joint = joint
self.id = 2
self.angle = None
self.value = None
self.xcoef = None
self.ycoef = None
def givexcoef(self, value):
self.xcoef = value
def giveycoef(self, value):
self.ycoef = value
def getangle(self):
assert self.xcoef != None and self.ycoef != None , "both coeficients need to be defined in order to calculate angle"
if self.angle != None:
self.angle = math.arctan2(self.ycoef, self.xcoef)
return self.angle
else: return self.angle
def reset(self):
self.value = None
self.xcoef = None
self.ycoef = None
self.angle = None