topologicpy 0.5.9__py3-none-any.whl → 6.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- topologicpy/Aperture.py +72 -72
- topologicpy/Cell.py +2169 -2169
- topologicpy/CellComplex.py +1137 -1137
- topologicpy/Cluster.py +1288 -1280
- topologicpy/Color.py +423 -423
- topologicpy/Context.py +79 -79
- topologicpy/DGL.py +3213 -3240
- topologicpy/Dictionary.py +698 -698
- topologicpy/Edge.py +1187 -1187
- topologicpy/EnergyModel.py +1180 -1152
- topologicpy/Face.py +2141 -2141
- topologicpy/Graph.py +7768 -7768
- topologicpy/Grid.py +353 -353
- topologicpy/Helper.py +507 -507
- topologicpy/Honeybee.py +461 -461
- topologicpy/Matrix.py +271 -271
- topologicpy/Neo4j.py +521 -521
- topologicpy/Plotly.py +2 -2
- topologicpy/Polyskel.py +541 -541
- topologicpy/Shell.py +1768 -1768
- topologicpy/Speckle.py +508 -508
- topologicpy/Topology.py +7060 -7002
- topologicpy/Vector.py +905 -905
- topologicpy/Vertex.py +1585 -1585
- topologicpy/Wire.py +3050 -3050
- topologicpy/__init__.py +22 -38
- topologicpy/version.py +1 -0
- {topologicpy-0.5.9.dist-info → topologicpy-6.0.0.dist-info}/LICENSE +661 -704
- topologicpy-6.0.0.dist-info/METADATA +751 -0
- topologicpy-6.0.0.dist-info/RECORD +32 -0
- topologicpy/bin/linux/topologic/__init__.py +0 -2
- topologicpy/bin/linux/topologic/libTKBO-6bdf205d.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKBRep-2960a069.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKBool-c44b74bd.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKFillet-9a670ba0.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKG2d-8f31849e.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKG3d-4c6bce57.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKGeomAlgo-26066fd9.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKGeomBase-2116cabe.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKMath-72572fa8.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKMesh-2a060427.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKOffset-6cab68ff.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKPrim-eb1262b3.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKShHealing-e67e5cc7.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKTopAlgo-e4c96c33.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKernel-fb7fe3b7.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libgcc_s-32c1665e.so.1 +0 -0
- topologicpy/bin/linux/topologic/libstdc++-672d7b41.so.6.0.30 +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-310-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-311-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-38-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-39-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic.libs/libTKBO-6bdf205d.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKBRep-2960a069.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKBool-c44b74bd.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKFillet-9a670ba0.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKG2d-8f31849e.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKG3d-4c6bce57.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKGeomAlgo-26066fd9.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKGeomBase-2116cabe.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKMath-72572fa8.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKMesh-2a060427.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKOffset-6cab68ff.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKPrim-eb1262b3.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKShHealing-e67e5cc7.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKTopAlgo-e4c96c33.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKernel-fb7fe3b7.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libgcc_s-32c1665e.so.1 +0 -0
- topologicpy/bin/linux/topologic.libs/libstdc++-672d7b41.so.6.0.30 +0 -0
- topologicpy/bin/macos/topologic/__init__.py +0 -2
- topologicpy/bin/windows/topologic/TKBO-f6b191de.dll +0 -0
- topologicpy/bin/windows/topologic/TKBRep-e56a600e.dll +0 -0
- topologicpy/bin/windows/topologic/TKBool-7b8d47ae.dll +0 -0
- topologicpy/bin/windows/topologic/TKFillet-0ddbf0a8.dll +0 -0
- topologicpy/bin/windows/topologic/TKG2d-2e2dee3d.dll +0 -0
- topologicpy/bin/windows/topologic/TKG3d-6674513d.dll +0 -0
- topologicpy/bin/windows/topologic/TKGeomAlgo-d240e370.dll +0 -0
- topologicpy/bin/windows/topologic/TKGeomBase-df87aba5.dll +0 -0
- topologicpy/bin/windows/topologic/TKMath-45bd625a.dll +0 -0
- topologicpy/bin/windows/topologic/TKMesh-d6e826b1.dll +0 -0
- topologicpy/bin/windows/topologic/TKOffset-79b9cc94.dll +0 -0
- topologicpy/bin/windows/topologic/TKPrim-aa430a86.dll +0 -0
- topologicpy/bin/windows/topologic/TKShHealing-bb48be89.dll +0 -0
- topologicpy/bin/windows/topologic/TKTopAlgo-7d0d1e22.dll +0 -0
- topologicpy/bin/windows/topologic/TKernel-08c8cfbb.dll +0 -0
- topologicpy/bin/windows/topologic/__init__.py +0 -2
- topologicpy/bin/windows/topologic/topologic.cp310-win_amd64.pyd +0 -0
- topologicpy/bin/windows/topologic/topologic.cp311-win_amd64.pyd +0 -0
- topologicpy/bin/windows/topologic/topologic.cp38-win_amd64.pyd +0 -0
- topologicpy/bin/windows/topologic/topologic.cp39-win_amd64.pyd +0 -0
- topologicpy-0.5.9.dist-info/METADATA +0 -86
- topologicpy-0.5.9.dist-info/RECORD +0 -91
- {topologicpy-0.5.9.dist-info → topologicpy-6.0.0.dist-info}/WHEEL +0 -0
- {topologicpy-0.5.9.dist-info → topologicpy-6.0.0.dist-info}/top_level.txt +0 -0
topologicpy/Matrix.py
CHANGED
@@ -1,271 +1,271 @@
|
|
1
|
-
# Copyright (C) 2024
|
2
|
-
# Wassim Jabi <wassim.jabi@gmail.com>
|
3
|
-
#
|
4
|
-
# This program is free software: you can redistribute it and/or modify it under
|
5
|
-
# the terms of the GNU Affero General Public License as published by the Free Software
|
6
|
-
# Foundation, either version 3 of the License, or (at your option) any later
|
7
|
-
# version.
|
8
|
-
#
|
9
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
10
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
11
|
-
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
12
|
-
# details.
|
13
|
-
#
|
14
|
-
# You should have received a copy of the GNU Affero General Public License along with
|
15
|
-
# this program. If not, see <https://www.gnu.org/licenses/>.
|
16
|
-
|
17
|
-
import math
|
18
|
-
|
19
|
-
class Matrix:
|
20
|
-
@staticmethod
|
21
|
-
def Add(matA, matB):
|
22
|
-
"""
|
23
|
-
Description
|
24
|
-
----------
|
25
|
-
Adds the two input matrices.
|
26
|
-
|
27
|
-
Parameters
|
28
|
-
----------
|
29
|
-
matA : list
|
30
|
-
The first input matrix.
|
31
|
-
matB : list
|
32
|
-
The second input matrix.
|
33
|
-
|
34
|
-
Returns
|
35
|
-
-------
|
36
|
-
list
|
37
|
-
The matrix resulting from the addition of the two input matrices.
|
38
|
-
|
39
|
-
"""
|
40
|
-
matC = []
|
41
|
-
if not isinstance(matA, list):
|
42
|
-
return None
|
43
|
-
if not isinstance(matB, list):
|
44
|
-
return None
|
45
|
-
for i in range(len(matA)):
|
46
|
-
tempRow = []
|
47
|
-
for j in range(len(matB)):
|
48
|
-
tempRow.append(matA[i][j] + matB[i][j])
|
49
|
-
matC.append(tempRow)
|
50
|
-
return matC
|
51
|
-
|
52
|
-
@staticmethod
|
53
|
-
def ByRotation(rx=0, ry=0, rz=0, order="xyz"):
|
54
|
-
"""
|
55
|
-
Description
|
56
|
-
----------
|
57
|
-
Creates a 4x4 rotation matrix.
|
58
|
-
|
59
|
-
Parameters
|
60
|
-
----------
|
61
|
-
rx : float , optional
|
62
|
-
The desired rotation around the X axis. The default is 0.
|
63
|
-
ry : float , optional
|
64
|
-
The desired rotation around the Y axis. The default is 0.
|
65
|
-
rz : float , optional
|
66
|
-
The desired rotation around the Z axis. The default is 0.
|
67
|
-
order : string , optional
|
68
|
-
The order by which the roatations will be applied. The possible values are any permutation of "xyz". This input is case insensitive. The default is "xyz".
|
69
|
-
|
70
|
-
Returns
|
71
|
-
-------
|
72
|
-
list
|
73
|
-
The created 4X4 rotation matrix.
|
74
|
-
|
75
|
-
"""
|
76
|
-
def rotateXMatrix(radians):
|
77
|
-
""" Return matrix for rotating about the x-axis by 'radians' radians """
|
78
|
-
c = math.cos(radians)
|
79
|
-
s = math.sin(radians)
|
80
|
-
return [[1, 0, 0, 0],
|
81
|
-
[0, c,-s, 0],
|
82
|
-
[0, s, c, 0],
|
83
|
-
[0, 0, 0, 1]]
|
84
|
-
|
85
|
-
def rotateYMatrix(radians):
|
86
|
-
""" Return matrix for rotating about the y-axis by 'radians' radians """
|
87
|
-
|
88
|
-
c = math.cos(radians)
|
89
|
-
s = math.sin(radians)
|
90
|
-
return [[ c, 0, s, 0],
|
91
|
-
[ 0, 1, 0, 0],
|
92
|
-
[-s, 0, c, 0],
|
93
|
-
[ 0, 0, 0, 1]]
|
94
|
-
|
95
|
-
def rotateZMatrix(radians):
|
96
|
-
""" Return matrix for rotating about the z-axis by 'radians' radians """
|
97
|
-
|
98
|
-
c = math.cos(radians)
|
99
|
-
s = math.sin(radians)
|
100
|
-
return [[c,-s, 0, 0],
|
101
|
-
[s, c, 0, 0],
|
102
|
-
[0, 0, 1, 0],
|
103
|
-
[0, 0, 0, 1]]
|
104
|
-
|
105
|
-
xMat = rotateXMatrix(math.radians(rx))
|
106
|
-
yMat = rotateYMatrix(math.radians(ry))
|
107
|
-
zMat = rotateZMatrix(math.radians(rz))
|
108
|
-
if order.lower() == "xyz":
|
109
|
-
return Matrix.Multiply(Matrix.Multiply(zMat,yMat),xMat)
|
110
|
-
if order.lower() == "xzy":
|
111
|
-
return Matrix.Multiply(Matrix.Multiply(yMat,zMat),xMat)
|
112
|
-
if order.lower() == "yxz":
|
113
|
-
return Matrix.Multiply(Matrix.Multiply(zMat,xMat),yMat)
|
114
|
-
if order.lower == "yzx":
|
115
|
-
return Matrix.Multiply(Matrix.Multiply(xMat,zMat),yMat)
|
116
|
-
if order.lower() == "zxy":
|
117
|
-
return Matrix.Multiply(Matrix.Multiply(yMat,xMat),zMat)
|
118
|
-
if order.lower() == "zyx":
|
119
|
-
return Matrix.Multiply(Matrix.Multiply(xMat,yMat),zMat)
|
120
|
-
|
121
|
-
@staticmethod
|
122
|
-
def ByScaling(sx=1.0, sy=1.0, sz=1.0):
|
123
|
-
"""
|
124
|
-
Description
|
125
|
-
----------
|
126
|
-
Creates a 4x4 scaling matrix.
|
127
|
-
|
128
|
-
Parameters
|
129
|
-
----------
|
130
|
-
sx : float , optional
|
131
|
-
The desired scaling factor along the X axis. The default is 1.
|
132
|
-
sy : float , optional
|
133
|
-
The desired scaling factor along the X axis. The default is 1.
|
134
|
-
sz : float , optional
|
135
|
-
The desired scaling factor along the X axis. The default is 1.
|
136
|
-
|
137
|
-
Returns
|
138
|
-
-------
|
139
|
-
list
|
140
|
-
The created 4X4 scaling matrix.
|
141
|
-
|
142
|
-
"""
|
143
|
-
return Matrix.Transpose([[sx,0,0,0],
|
144
|
-
[0,sy,0,0],
|
145
|
-
[0,0,sz,0],
|
146
|
-
[0,0,0,1]])
|
147
|
-
|
148
|
-
@staticmethod
|
149
|
-
def ByTranslation(tx=0, ty=0, tz=0):
|
150
|
-
"""
|
151
|
-
Description
|
152
|
-
----------
|
153
|
-
Creates a 4x4 translation matrix.
|
154
|
-
|
155
|
-
Parameters
|
156
|
-
----------
|
157
|
-
tx : float , optional
|
158
|
-
The desired translation distance along the X axis. The default is 0.
|
159
|
-
ty : float , optional
|
160
|
-
The desired translation distance along the X axis. The default is 0.
|
161
|
-
tz : float , optional
|
162
|
-
The desired translation distance along the X axis. The default is 0.
|
163
|
-
|
164
|
-
Returns
|
165
|
-
-------
|
166
|
-
list
|
167
|
-
The created 4X4 translation matrix.
|
168
|
-
|
169
|
-
"""
|
170
|
-
return Matrix.Transpose([[1,0,0,tx],
|
171
|
-
[0,1,0,ty],
|
172
|
-
[0,0,1,tz],
|
173
|
-
[0,0,0,1]])
|
174
|
-
|
175
|
-
@staticmethod
|
176
|
-
def Multiply(matA, matB):
|
177
|
-
"""
|
178
|
-
Description
|
179
|
-
----------
|
180
|
-
Multiplies the two input matrices.
|
181
|
-
|
182
|
-
Parameters
|
183
|
-
----------
|
184
|
-
matA : list
|
185
|
-
The first input matrix.
|
186
|
-
matB : list
|
187
|
-
The second input matrix.
|
188
|
-
|
189
|
-
Returns
|
190
|
-
-------
|
191
|
-
list
|
192
|
-
The matrix resulting from the multiplication of the two input matrices.
|
193
|
-
|
194
|
-
"""
|
195
|
-
if not isinstance(matA, list):
|
196
|
-
return None
|
197
|
-
if not isinstance(matB, list):
|
198
|
-
return None
|
199
|
-
nr = len(matA)
|
200
|
-
nc = len(matA[0])
|
201
|
-
matC = []
|
202
|
-
for i in range(nr):
|
203
|
-
tempRow = []
|
204
|
-
for j in range(nc):
|
205
|
-
tempRow.append(0)
|
206
|
-
matC.append(tempRow)
|
207
|
-
if not isinstance(matA, list):
|
208
|
-
return None
|
209
|
-
if not isinstance(matB, list):
|
210
|
-
return None
|
211
|
-
# iterate through rows of X
|
212
|
-
for i in range(len(matA)):
|
213
|
-
# iterate through columns of Y
|
214
|
-
tempRow = []
|
215
|
-
for j in range(len(matB[0])):
|
216
|
-
# iterate through rows of Y
|
217
|
-
for k in range(len(matB)):
|
218
|
-
matC[i][j] += matA[i][k] * matB[k][j]
|
219
|
-
return matC
|
220
|
-
|
221
|
-
@staticmethod
|
222
|
-
def Subtract(matA, matB):
|
223
|
-
"""
|
224
|
-
Description
|
225
|
-
----------
|
226
|
-
Subtracts the two input matrices.
|
227
|
-
|
228
|
-
Parameters
|
229
|
-
----------
|
230
|
-
matA : list
|
231
|
-
The first input matrix.
|
232
|
-
matB : list
|
233
|
-
The second input matrix.
|
234
|
-
|
235
|
-
Returns
|
236
|
-
-------
|
237
|
-
list
|
238
|
-
The matrix resulting from the subtraction of the second input matrix from the first input matrix.
|
239
|
-
|
240
|
-
"""
|
241
|
-
if not isinstance(matA, list):
|
242
|
-
return None
|
243
|
-
if not isinstance(matB, list):
|
244
|
-
return None
|
245
|
-
matC = []
|
246
|
-
for i in range(len(matA)):
|
247
|
-
tempRow = []
|
248
|
-
for j in range(len(matB)):
|
249
|
-
tempRow.append(matA[i][j] - matB[i][j])
|
250
|
-
matC.append(tempRow)
|
251
|
-
return matC
|
252
|
-
|
253
|
-
@staticmethod
|
254
|
-
def Transpose(matrix):
|
255
|
-
"""
|
256
|
-
Description
|
257
|
-
----------
|
258
|
-
Transposes the input matrix.
|
259
|
-
|
260
|
-
Parameters
|
261
|
-
----------
|
262
|
-
matrix : list
|
263
|
-
The input matrix.
|
264
|
-
|
265
|
-
Returns
|
266
|
-
-------
|
267
|
-
list
|
268
|
-
The transposed matrix.
|
269
|
-
|
270
|
-
"""
|
271
|
-
return [list(x) for x in zip(*matrix)]
|
1
|
+
# Copyright (C) 2024
|
2
|
+
# Wassim Jabi <wassim.jabi@gmail.com>
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify it under
|
5
|
+
# the terms of the GNU Affero General Public License as published by the Free Software
|
6
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
7
|
+
# version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
10
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
11
|
+
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
12
|
+
# details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU Affero General Public License along with
|
15
|
+
# this program. If not, see <https://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
import math
|
18
|
+
|
19
|
+
class Matrix:
|
20
|
+
@staticmethod
|
21
|
+
def Add(matA, matB):
|
22
|
+
"""
|
23
|
+
Description
|
24
|
+
----------
|
25
|
+
Adds the two input matrices.
|
26
|
+
|
27
|
+
Parameters
|
28
|
+
----------
|
29
|
+
matA : list
|
30
|
+
The first input matrix.
|
31
|
+
matB : list
|
32
|
+
The second input matrix.
|
33
|
+
|
34
|
+
Returns
|
35
|
+
-------
|
36
|
+
list
|
37
|
+
The matrix resulting from the addition of the two input matrices.
|
38
|
+
|
39
|
+
"""
|
40
|
+
matC = []
|
41
|
+
if not isinstance(matA, list):
|
42
|
+
return None
|
43
|
+
if not isinstance(matB, list):
|
44
|
+
return None
|
45
|
+
for i in range(len(matA)):
|
46
|
+
tempRow = []
|
47
|
+
for j in range(len(matB)):
|
48
|
+
tempRow.append(matA[i][j] + matB[i][j])
|
49
|
+
matC.append(tempRow)
|
50
|
+
return matC
|
51
|
+
|
52
|
+
@staticmethod
|
53
|
+
def ByRotation(rx=0, ry=0, rz=0, order="xyz"):
|
54
|
+
"""
|
55
|
+
Description
|
56
|
+
----------
|
57
|
+
Creates a 4x4 rotation matrix.
|
58
|
+
|
59
|
+
Parameters
|
60
|
+
----------
|
61
|
+
rx : float , optional
|
62
|
+
The desired rotation around the X axis. The default is 0.
|
63
|
+
ry : float , optional
|
64
|
+
The desired rotation around the Y axis. The default is 0.
|
65
|
+
rz : float , optional
|
66
|
+
The desired rotation around the Z axis. The default is 0.
|
67
|
+
order : string , optional
|
68
|
+
The order by which the roatations will be applied. The possible values are any permutation of "xyz". This input is case insensitive. The default is "xyz".
|
69
|
+
|
70
|
+
Returns
|
71
|
+
-------
|
72
|
+
list
|
73
|
+
The created 4X4 rotation matrix.
|
74
|
+
|
75
|
+
"""
|
76
|
+
def rotateXMatrix(radians):
|
77
|
+
""" Return matrix for rotating about the x-axis by 'radians' radians """
|
78
|
+
c = math.cos(radians)
|
79
|
+
s = math.sin(radians)
|
80
|
+
return [[1, 0, 0, 0],
|
81
|
+
[0, c,-s, 0],
|
82
|
+
[0, s, c, 0],
|
83
|
+
[0, 0, 0, 1]]
|
84
|
+
|
85
|
+
def rotateYMatrix(radians):
|
86
|
+
""" Return matrix for rotating about the y-axis by 'radians' radians """
|
87
|
+
|
88
|
+
c = math.cos(radians)
|
89
|
+
s = math.sin(radians)
|
90
|
+
return [[ c, 0, s, 0],
|
91
|
+
[ 0, 1, 0, 0],
|
92
|
+
[-s, 0, c, 0],
|
93
|
+
[ 0, 0, 0, 1]]
|
94
|
+
|
95
|
+
def rotateZMatrix(radians):
|
96
|
+
""" Return matrix for rotating about the z-axis by 'radians' radians """
|
97
|
+
|
98
|
+
c = math.cos(radians)
|
99
|
+
s = math.sin(radians)
|
100
|
+
return [[c,-s, 0, 0],
|
101
|
+
[s, c, 0, 0],
|
102
|
+
[0, 0, 1, 0],
|
103
|
+
[0, 0, 0, 1]]
|
104
|
+
|
105
|
+
xMat = rotateXMatrix(math.radians(rx))
|
106
|
+
yMat = rotateYMatrix(math.radians(ry))
|
107
|
+
zMat = rotateZMatrix(math.radians(rz))
|
108
|
+
if order.lower() == "xyz":
|
109
|
+
return Matrix.Multiply(Matrix.Multiply(zMat,yMat),xMat)
|
110
|
+
if order.lower() == "xzy":
|
111
|
+
return Matrix.Multiply(Matrix.Multiply(yMat,zMat),xMat)
|
112
|
+
if order.lower() == "yxz":
|
113
|
+
return Matrix.Multiply(Matrix.Multiply(zMat,xMat),yMat)
|
114
|
+
if order.lower == "yzx":
|
115
|
+
return Matrix.Multiply(Matrix.Multiply(xMat,zMat),yMat)
|
116
|
+
if order.lower() == "zxy":
|
117
|
+
return Matrix.Multiply(Matrix.Multiply(yMat,xMat),zMat)
|
118
|
+
if order.lower() == "zyx":
|
119
|
+
return Matrix.Multiply(Matrix.Multiply(xMat,yMat),zMat)
|
120
|
+
|
121
|
+
@staticmethod
|
122
|
+
def ByScaling(sx=1.0, sy=1.0, sz=1.0):
|
123
|
+
"""
|
124
|
+
Description
|
125
|
+
----------
|
126
|
+
Creates a 4x4 scaling matrix.
|
127
|
+
|
128
|
+
Parameters
|
129
|
+
----------
|
130
|
+
sx : float , optional
|
131
|
+
The desired scaling factor along the X axis. The default is 1.
|
132
|
+
sy : float , optional
|
133
|
+
The desired scaling factor along the X axis. The default is 1.
|
134
|
+
sz : float , optional
|
135
|
+
The desired scaling factor along the X axis. The default is 1.
|
136
|
+
|
137
|
+
Returns
|
138
|
+
-------
|
139
|
+
list
|
140
|
+
The created 4X4 scaling matrix.
|
141
|
+
|
142
|
+
"""
|
143
|
+
return Matrix.Transpose([[sx,0,0,0],
|
144
|
+
[0,sy,0,0],
|
145
|
+
[0,0,sz,0],
|
146
|
+
[0,0,0,1]])
|
147
|
+
|
148
|
+
@staticmethod
|
149
|
+
def ByTranslation(tx=0, ty=0, tz=0):
|
150
|
+
"""
|
151
|
+
Description
|
152
|
+
----------
|
153
|
+
Creates a 4x4 translation matrix.
|
154
|
+
|
155
|
+
Parameters
|
156
|
+
----------
|
157
|
+
tx : float , optional
|
158
|
+
The desired translation distance along the X axis. The default is 0.
|
159
|
+
ty : float , optional
|
160
|
+
The desired translation distance along the X axis. The default is 0.
|
161
|
+
tz : float , optional
|
162
|
+
The desired translation distance along the X axis. The default is 0.
|
163
|
+
|
164
|
+
Returns
|
165
|
+
-------
|
166
|
+
list
|
167
|
+
The created 4X4 translation matrix.
|
168
|
+
|
169
|
+
"""
|
170
|
+
return Matrix.Transpose([[1,0,0,tx],
|
171
|
+
[0,1,0,ty],
|
172
|
+
[0,0,1,tz],
|
173
|
+
[0,0,0,1]])
|
174
|
+
|
175
|
+
@staticmethod
|
176
|
+
def Multiply(matA, matB):
|
177
|
+
"""
|
178
|
+
Description
|
179
|
+
----------
|
180
|
+
Multiplies the two input matrices.
|
181
|
+
|
182
|
+
Parameters
|
183
|
+
----------
|
184
|
+
matA : list
|
185
|
+
The first input matrix.
|
186
|
+
matB : list
|
187
|
+
The second input matrix.
|
188
|
+
|
189
|
+
Returns
|
190
|
+
-------
|
191
|
+
list
|
192
|
+
The matrix resulting from the multiplication of the two input matrices.
|
193
|
+
|
194
|
+
"""
|
195
|
+
if not isinstance(matA, list):
|
196
|
+
return None
|
197
|
+
if not isinstance(matB, list):
|
198
|
+
return None
|
199
|
+
nr = len(matA)
|
200
|
+
nc = len(matA[0])
|
201
|
+
matC = []
|
202
|
+
for i in range(nr):
|
203
|
+
tempRow = []
|
204
|
+
for j in range(nc):
|
205
|
+
tempRow.append(0)
|
206
|
+
matC.append(tempRow)
|
207
|
+
if not isinstance(matA, list):
|
208
|
+
return None
|
209
|
+
if not isinstance(matB, list):
|
210
|
+
return None
|
211
|
+
# iterate through rows of X
|
212
|
+
for i in range(len(matA)):
|
213
|
+
# iterate through columns of Y
|
214
|
+
tempRow = []
|
215
|
+
for j in range(len(matB[0])):
|
216
|
+
# iterate through rows of Y
|
217
|
+
for k in range(len(matB)):
|
218
|
+
matC[i][j] += matA[i][k] * matB[k][j]
|
219
|
+
return matC
|
220
|
+
|
221
|
+
@staticmethod
|
222
|
+
def Subtract(matA, matB):
|
223
|
+
"""
|
224
|
+
Description
|
225
|
+
----------
|
226
|
+
Subtracts the two input matrices.
|
227
|
+
|
228
|
+
Parameters
|
229
|
+
----------
|
230
|
+
matA : list
|
231
|
+
The first input matrix.
|
232
|
+
matB : list
|
233
|
+
The second input matrix.
|
234
|
+
|
235
|
+
Returns
|
236
|
+
-------
|
237
|
+
list
|
238
|
+
The matrix resulting from the subtraction of the second input matrix from the first input matrix.
|
239
|
+
|
240
|
+
"""
|
241
|
+
if not isinstance(matA, list):
|
242
|
+
return None
|
243
|
+
if not isinstance(matB, list):
|
244
|
+
return None
|
245
|
+
matC = []
|
246
|
+
for i in range(len(matA)):
|
247
|
+
tempRow = []
|
248
|
+
for j in range(len(matB)):
|
249
|
+
tempRow.append(matA[i][j] - matB[i][j])
|
250
|
+
matC.append(tempRow)
|
251
|
+
return matC
|
252
|
+
|
253
|
+
@staticmethod
|
254
|
+
def Transpose(matrix):
|
255
|
+
"""
|
256
|
+
Description
|
257
|
+
----------
|
258
|
+
Transposes the input matrix.
|
259
|
+
|
260
|
+
Parameters
|
261
|
+
----------
|
262
|
+
matrix : list
|
263
|
+
The input matrix.
|
264
|
+
|
265
|
+
Returns
|
266
|
+
-------
|
267
|
+
list
|
268
|
+
The transposed matrix.
|
269
|
+
|
270
|
+
"""
|
271
|
+
return [list(x) for x in zip(*matrix)]
|