ncca-ngl 0.2.2__tar.gz → 0.2.3__tar.gz
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.
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/PKG-INFO +1 -1
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/pyproject.toml +1 -1
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/__init__.py +3 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/mat2.py +12 -2
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/mat3.py +34 -44
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/mat4.py +14 -4
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/vec2.py +4 -7
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/vec3.py +11 -25
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/vec4.py +5 -17
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/LICENSE.txt +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/.ruff_cache/.gitignore +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/.ruff_cache/0.13.0/10564494386971134025 +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/.ruff_cache/0.13.0/7783445477288392980 +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/.ruff_cache/CACHEDIR.TAG +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/PrimData/Primitives.npz +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/PrimData/buddah.npy +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/PrimData/bunny.npy +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/PrimData/cube.npy +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/PrimData/dodecahedron.npy +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/PrimData/dragon.npy +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/PrimData/football.npy +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/PrimData/icosahedron.npy +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/PrimData/octahedron.npy +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/PrimData/pack_arrays.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/PrimData/teapot.npy +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/PrimData/tetrahedron.npy +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/PrimData/troll.npy +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/abstract_vao.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/base_mesh.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/base_mesh.pyi +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/bbox.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/bezier_curve.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/first_person_camera.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/image.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/log.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/multi_buffer_vao.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/obj.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/plane.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/prim_data.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/primitives.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/pyside_event_handling_mixin.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/quaternion.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/random.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/shader.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/shader_lib.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/shader_program.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/shaders/checker_fragment.glsl +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/shaders/checker_vertex.glsl +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/shaders/colour_fragment.glsl +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/shaders/colour_vertex.glsl +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/shaders/diffuse_fragment.glsl +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/shaders/diffuse_vertex.glsl +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/shaders/text_fragment.glsl +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/shaders/text_geometry.glsl +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/shaders/text_vertex.glsl +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/simple_index_vao.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/simple_vao.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/text.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/texture.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/transform.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/util.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/vao_factory.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/vec2_array.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/vec3_array.py +0 -0
- {ncca_ngl-0.2.2 → ncca_ngl-0.2.3}/src/ncca/ngl/vec4_array.py +0 -0
|
@@ -45,7 +45,7 @@ class Mat2:
|
|
|
45
45
|
Returns:
|
|
46
46
|
list[float]: A flat list of floats.
|
|
47
47
|
"""
|
|
48
|
-
return [item for sublist in zip(*self.m) for item in sublist]
|
|
48
|
+
return [item for sublist in zip(*self.m, strict=False) for item in sublist]
|
|
49
49
|
|
|
50
50
|
def to_numpy(self):
|
|
51
51
|
"""
|
|
@@ -125,4 +125,14 @@ class Mat2:
|
|
|
125
125
|
def to_list(self):
|
|
126
126
|
"convert matrix to list in column-major order"
|
|
127
127
|
# flatten to single array
|
|
128
|
-
return [item for sublist in zip(*self.m) for item in sublist]
|
|
128
|
+
return [item for sublist in zip(*self.m, strict=False) for item in sublist]
|
|
129
|
+
|
|
130
|
+
def copy(self) -> "Mat2":
|
|
131
|
+
"""Create a copy of the matrix.
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
A new Mat2 instance with the same values.
|
|
135
|
+
"""
|
|
136
|
+
new_mat = Mat2()
|
|
137
|
+
new_mat.m = copy.deepcopy(self.m)
|
|
138
|
+
return new_mat
|
|
@@ -132,7 +132,7 @@ class Mat3:
|
|
|
132
132
|
|
|
133
133
|
def transpose(self):
|
|
134
134
|
"""transpose this matrix"""
|
|
135
|
-
self.m = [list(item) for item in zip(*self.m)]
|
|
135
|
+
self.m = [list(item) for item in zip(*self.m, strict=False)]
|
|
136
136
|
|
|
137
137
|
def get_transpose(self):
|
|
138
138
|
"""return a new matrix as the transpose of ourself
|
|
@@ -143,7 +143,7 @@ class Mat3:
|
|
|
143
143
|
The transpose of the current matrix
|
|
144
144
|
"""
|
|
145
145
|
m = Mat3()
|
|
146
|
-
m.m = [list(item) for item in zip(*self.m)]
|
|
146
|
+
m.m = [list(item) for item in zip(*self.m, strict=False)]
|
|
147
147
|
return m
|
|
148
148
|
|
|
149
149
|
@classmethod
|
|
@@ -360,7 +360,7 @@ class Mat3:
|
|
|
360
360
|
"internal add function"
|
|
361
361
|
temp = Mat3()
|
|
362
362
|
for i in range(0, len(temp.m)):
|
|
363
|
-
temp.m[i] = [a + b for a, b in zip(self.m[i], rhs.m[i])]
|
|
363
|
+
temp.m[i] = [a + b for a, b in zip(self.m[i], rhs.m[i], strict=False)]
|
|
364
364
|
return temp
|
|
365
365
|
|
|
366
366
|
def __add__(self, rhs):
|
|
@@ -375,7 +375,7 @@ class Mat3:
|
|
|
375
375
|
"internal subtract function"
|
|
376
376
|
temp = Mat3()
|
|
377
377
|
for i in range(0, len(temp.m)):
|
|
378
|
-
temp.m[i] = [a - b for a, b in zip(self.m[i], rhs.m[i])]
|
|
378
|
+
temp.m[i] = [a - b for a, b in zip(self.m[i], rhs.m[i], strict=False)]
|
|
379
379
|
return temp
|
|
380
380
|
|
|
381
381
|
def __sub__(self, rhs):
|
|
@@ -399,6 +399,16 @@ class Mat3:
|
|
|
399
399
|
# flatten to single array
|
|
400
400
|
return functools.reduce(operator.concat, self.m)
|
|
401
401
|
|
|
402
|
+
def copy(self) -> "Mat3":
|
|
403
|
+
"""Create a copy of the matrix.
|
|
404
|
+
|
|
405
|
+
Returns:
|
|
406
|
+
A new Mat3 instance with the same values.
|
|
407
|
+
"""
|
|
408
|
+
new_mat = Mat3()
|
|
409
|
+
new_mat.m = copy.deepcopy(self.m)
|
|
410
|
+
return new_mat
|
|
411
|
+
|
|
402
412
|
def inverse(self):
|
|
403
413
|
"Inverse of matrix raise MatrixError if not calculable"
|
|
404
414
|
det = self.determinant()
|
|
@@ -406,35 +416,17 @@ class Mat3:
|
|
|
406
416
|
invdet = 1 / det
|
|
407
417
|
tmp = Mat3()
|
|
408
418
|
# minor matrix + co-factor
|
|
409
|
-
tmp.m[0][0] = (
|
|
410
|
-
|
|
411
|
-
)
|
|
412
|
-
tmp.m[1][0] = (
|
|
413
|
-
-(self.m[1][0] * self.m[2][2] - self.m[1][2] * self.m[2][0]) * invdet
|
|
414
|
-
)
|
|
415
|
-
tmp.m[2][0] = (
|
|
416
|
-
+(self.m[1][0] * self.m[2][1] - self.m[1][1] * self.m[2][0]) * invdet
|
|
417
|
-
)
|
|
419
|
+
tmp.m[0][0] = +(self.m[1][1] * self.m[2][2] - self.m[1][2] * self.m[2][1]) * invdet
|
|
420
|
+
tmp.m[1][0] = -(self.m[1][0] * self.m[2][2] - self.m[1][2] * self.m[2][0]) * invdet
|
|
421
|
+
tmp.m[2][0] = +(self.m[1][0] * self.m[2][1] - self.m[1][1] * self.m[2][0]) * invdet
|
|
418
422
|
|
|
419
|
-
tmp.m[0][1] = (
|
|
420
|
-
|
|
421
|
-
)
|
|
422
|
-
tmp.m[1][1] = (
|
|
423
|
-
+(self.m[0][0] * self.m[2][2] - self.m[0][2] * self.m[2][0]) * invdet
|
|
424
|
-
)
|
|
425
|
-
tmp.m[2][1] = (
|
|
426
|
-
-(self.m[0][0] * self.m[2][1] - self.m[0][1] * self.m[2][0]) * invdet
|
|
427
|
-
)
|
|
423
|
+
tmp.m[0][1] = -(self.m[0][1] * self.m[2][2] - self.m[0][2] * self.m[2][1]) * invdet
|
|
424
|
+
tmp.m[1][1] = +(self.m[0][0] * self.m[2][2] - self.m[0][2] * self.m[2][0]) * invdet
|
|
425
|
+
tmp.m[2][1] = -(self.m[0][0] * self.m[2][1] - self.m[0][1] * self.m[2][0]) * invdet
|
|
428
426
|
|
|
429
|
-
tmp.m[0][2] = (
|
|
430
|
-
|
|
431
|
-
)
|
|
432
|
-
tmp.m[1][2] = (
|
|
433
|
-
-(self.m[0][0] * self.m[1][2] - self.m[0][2] * self.m[1][0]) * invdet
|
|
434
|
-
)
|
|
435
|
-
tmp.m[2][2] = (
|
|
436
|
-
+(self.m[0][0] * self.m[1][1] - self.m[0][1] * self.m[1][0]) * invdet
|
|
437
|
-
)
|
|
427
|
+
tmp.m[0][2] = +(self.m[0][1] * self.m[1][2] - self.m[0][2] * self.m[1][1]) * invdet
|
|
428
|
+
tmp.m[1][2] = -(self.m[0][0] * self.m[1][2] - self.m[0][2] * self.m[1][0]) * invdet
|
|
429
|
+
tmp.m[2][2] = +(self.m[0][0] * self.m[1][1] - self.m[0][1] * self.m[1][0]) * invdet
|
|
438
430
|
|
|
439
431
|
return tmp
|
|
440
432
|
except ZeroDivisionError:
|
|
@@ -451,16 +443,14 @@ class Mat3:
|
|
|
451
443
|
@classmethod
|
|
452
444
|
def from_mat4(cls, mat4):
|
|
453
445
|
"""Create a Mat3 from a Mat4"""
|
|
454
|
-
return Mat3.from_list(
|
|
455
|
-
[
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
]
|
|
466
|
-
)
|
|
446
|
+
return Mat3.from_list([
|
|
447
|
+
mat4.m[0][0],
|
|
448
|
+
mat4.m[0][1],
|
|
449
|
+
mat4.m[0][2],
|
|
450
|
+
mat4.m[1][0],
|
|
451
|
+
mat4.m[1][1],
|
|
452
|
+
mat4.m[1][2],
|
|
453
|
+
mat4.m[2][0],
|
|
454
|
+
mat4.m[2][1],
|
|
455
|
+
mat4.m[2][2],
|
|
456
|
+
])
|
|
@@ -86,14 +86,24 @@ class Mat4:
|
|
|
86
86
|
# flatten to single array
|
|
87
87
|
return functools.reduce(operator.concat, self.m)
|
|
88
88
|
|
|
89
|
+
def copy(self) -> "Mat4":
|
|
90
|
+
"""Create a copy of the matrix.
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
A new Mat4 instance with the same values.
|
|
94
|
+
"""
|
|
95
|
+
new_mat = Mat4()
|
|
96
|
+
new_mat.m = copy.deepcopy(self.m)
|
|
97
|
+
return new_mat
|
|
98
|
+
|
|
89
99
|
def transpose(self):
|
|
90
100
|
"transpose this matrix"
|
|
91
|
-
self.m = [list(item) for item in zip(*self.m)]
|
|
101
|
+
self.m = [list(item) for item in zip(*self.m, strict=False)]
|
|
92
102
|
|
|
93
103
|
def get_transpose(self):
|
|
94
104
|
"return a new matrix as the transpose of ourself"
|
|
95
105
|
m = Mat4()
|
|
96
|
-
m.m = [list(item) for item in zip(*self.m)]
|
|
106
|
+
m.m = [list(item) for item in zip(*self.m, strict=False)]
|
|
97
107
|
return m
|
|
98
108
|
|
|
99
109
|
@classmethod
|
|
@@ -258,7 +268,7 @@ class Mat4:
|
|
|
258
268
|
"internal add function"
|
|
259
269
|
temp = Mat4()
|
|
260
270
|
for i in range(0, len(temp.m)):
|
|
261
|
-
temp.m[i] = [a + b for a, b in zip(self.m[i], rhs.m[i])]
|
|
271
|
+
temp.m[i] = [a + b for a, b in zip(self.m[i], rhs.m[i], strict=False)]
|
|
262
272
|
return temp
|
|
263
273
|
|
|
264
274
|
def __add__(self, rhs):
|
|
@@ -273,7 +283,7 @@ class Mat4:
|
|
|
273
283
|
"internal sub function"
|
|
274
284
|
temp = Mat4()
|
|
275
285
|
for i in range(0, len(temp.m)):
|
|
276
|
-
temp.m[i] = [a - b for a, b in zip(self.m[i], rhs.m[i])]
|
|
286
|
+
temp.m[i] = [a - b for a, b in zip(self.m[i], rhs.m[i], strict=False)]
|
|
277
287
|
return temp
|
|
278
288
|
|
|
279
289
|
def __sub__(self, rhs):
|
|
@@ -42,7 +42,7 @@ class Vec2:
|
|
|
42
42
|
yield self.x
|
|
43
43
|
yield self.y
|
|
44
44
|
|
|
45
|
-
def
|
|
45
|
+
def copy(self) -> "Vec2":
|
|
46
46
|
"""
|
|
47
47
|
Create a copy of the vector.
|
|
48
48
|
Returns:
|
|
@@ -305,9 +305,7 @@ class Vec2:
|
|
|
305
305
|
if isinstance(rhs, (float, int)):
|
|
306
306
|
return Vec2(self.x * rhs, self.y * rhs)
|
|
307
307
|
else:
|
|
308
|
-
raise ValueError(
|
|
309
|
-
f"can only do piecewise multiplication with a scalar {rhs=}"
|
|
310
|
-
)
|
|
308
|
+
raise ValueError(f"can only do piecewise multiplication with a scalar {rhs=}")
|
|
311
309
|
|
|
312
310
|
def __rmul__(self, rhs):
|
|
313
311
|
"""
|
|
@@ -330,9 +328,8 @@ class Vec2:
|
|
|
330
328
|
Vec2: A new vector that is the result of multiplying this vector by the matrix.
|
|
331
329
|
"""
|
|
332
330
|
return Vec2(
|
|
333
|
-
self.x * rhs.m[0][0] + self.y * rhs.m[1][0]
|
|
334
|
-
self.x * rhs.m[0][1] + self.y * rhs.m[1][1]
|
|
335
|
-
self.x * rhs.m[0][2] + self.y * rhs.m[1][2] + self.z * rhs.m[2][2],
|
|
331
|
+
self.x * rhs.m[0][0] + self.y * rhs.m[1][0],
|
|
332
|
+
self.x * rhs.m[0][1] + self.y * rhs.m[1][1],
|
|
336
333
|
)
|
|
337
334
|
|
|
338
335
|
|
|
@@ -78,9 +78,9 @@ class Vec3:
|
|
|
78
78
|
else:
|
|
79
79
|
setattr(self, name, v)
|
|
80
80
|
|
|
81
|
-
def
|
|
81
|
+
def copy(self) -> "Vec3":
|
|
82
82
|
"""
|
|
83
|
-
Create a
|
|
83
|
+
Create a copy of the current vector.
|
|
84
84
|
Returns:
|
|
85
85
|
Vec3: A new instance of Vec3 with the same x, y, and z values.
|
|
86
86
|
"""
|
|
@@ -156,11 +156,7 @@ class Vec3:
|
|
|
156
156
|
|
|
157
157
|
if not isinstance(rhs, Vec3):
|
|
158
158
|
return NotImplemented
|
|
159
|
-
return (
|
|
160
|
-
math.isclose(self.x, rhs.x)
|
|
161
|
-
and math.isclose(self.y, rhs.y)
|
|
162
|
-
and math.isclose(self.z, rhs.z)
|
|
163
|
-
)
|
|
159
|
+
return math.isclose(self.x, rhs.x) and math.isclose(self.y, rhs.y) and math.isclose(self.z, rhs.z)
|
|
164
160
|
|
|
165
161
|
def __neq__(self, rhs):
|
|
166
162
|
"""
|
|
@@ -173,11 +169,7 @@ class Vec3:
|
|
|
173
169
|
"""
|
|
174
170
|
if not isinstance(rhs, Vec3):
|
|
175
171
|
return NotImplemented
|
|
176
|
-
return not (
|
|
177
|
-
math.isclose(self.x, rhs.x)
|
|
178
|
-
and math.isclose(self.y, rhs.y)
|
|
179
|
-
and math.isclose(self.z, rhs.z)
|
|
180
|
-
)
|
|
172
|
+
return not (math.isclose(self.x, rhs.x) and math.isclose(self.y, rhs.y) and math.isclose(self.z, rhs.z))
|
|
181
173
|
|
|
182
174
|
def __neg__(self):
|
|
183
175
|
"""
|
|
@@ -290,9 +282,7 @@ class Vec3:
|
|
|
290
282
|
"""
|
|
291
283
|
d = self.dot(n)
|
|
292
284
|
# I - 2.0 * dot(N, I) * N
|
|
293
|
-
return Vec3(
|
|
294
|
-
self.x - 2.0 * d * n.x, self.y - 2.0 * d * n.y, self.z - 2.0 * d * n.z
|
|
295
|
-
)
|
|
285
|
+
return Vec3(self.x - 2.0 * d * n.x, self.y - 2.0 * d * n.y, self.z - 2.0 * d * n.z)
|
|
296
286
|
|
|
297
287
|
def clamp(self, low, high):
|
|
298
288
|
"""
|
|
@@ -324,13 +314,11 @@ class Vec3:
|
|
|
324
314
|
"""
|
|
325
315
|
from .mat3 import Mat3
|
|
326
316
|
|
|
327
|
-
return Mat3.from_list(
|
|
328
|
-
[
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
]
|
|
333
|
-
)
|
|
317
|
+
return Mat3.from_list([
|
|
318
|
+
[self.x * rhs.x, self.x * rhs.y, self.x * rhs.z],
|
|
319
|
+
[self.y * rhs.x, self.y * rhs.y, self.y * rhs.z],
|
|
320
|
+
[self.z * rhs.x, self.z * rhs.y, self.z * rhs.z],
|
|
321
|
+
])
|
|
334
322
|
|
|
335
323
|
def __mul__(self, rhs):
|
|
336
324
|
"""
|
|
@@ -345,9 +333,7 @@ class Vec3:
|
|
|
345
333
|
if isinstance(rhs, (float, int)):
|
|
346
334
|
return Vec3(self.x * rhs, self.y * rhs, self.z * rhs)
|
|
347
335
|
else:
|
|
348
|
-
raise ValueError(
|
|
349
|
-
f"can only do piecewise multiplication with a scalar {rhs=}"
|
|
350
|
-
)
|
|
336
|
+
raise ValueError(f"can only do piecewise multiplication with a scalar {rhs=}")
|
|
351
337
|
|
|
352
338
|
def __rmul__(self, rhs):
|
|
353
339
|
"""
|
|
@@ -65,7 +65,7 @@ class Vec4:
|
|
|
65
65
|
except IndexError:
|
|
66
66
|
raise IndexError("Index out of range. Valid indices are 0, 1, 2, and 3.")
|
|
67
67
|
|
|
68
|
-
def
|
|
68
|
+
def copy(self) -> "Vec4":
|
|
69
69
|
"""
|
|
70
70
|
Create a copy of the vector.
|
|
71
71
|
Returns:
|
|
@@ -192,22 +192,10 @@ class Vec4:
|
|
|
192
192
|
def __matmul__(self, rhs):
|
|
193
193
|
"Vec4 @ Mat4 matrix multiplication"
|
|
194
194
|
return Vec4(
|
|
195
|
-
self.x * rhs.m[0][0]
|
|
196
|
-
+ self.y * rhs.m[1][
|
|
197
|
-
+ self.z * rhs.m[2][
|
|
198
|
-
+ self.w * rhs.m[3][
|
|
199
|
-
self.x * rhs.m[0][1]
|
|
200
|
-
+ self.y * rhs.m[1][1]
|
|
201
|
-
+ self.z * rhs.m[2][1]
|
|
202
|
-
+ self.w * rhs.m[3][1],
|
|
203
|
-
self.x * rhs.m[0][2]
|
|
204
|
-
+ self.y * rhs.m[1][2]
|
|
205
|
-
+ self.z * rhs.m[2][2]
|
|
206
|
-
+ self.w * rhs.m[3][2],
|
|
207
|
-
self.x * rhs.m[0][3]
|
|
208
|
-
+ self.y * rhs.m[1][3]
|
|
209
|
-
+ self.z * rhs.m[2][3]
|
|
210
|
-
+ self.w * rhs.m[3][3],
|
|
195
|
+
self.x * rhs.m[0][0] + self.y * rhs.m[1][0] + self.z * rhs.m[2][0] + self.w * rhs.m[3][0],
|
|
196
|
+
self.x * rhs.m[0][1] + self.y * rhs.m[1][1] + self.z * rhs.m[2][1] + self.w * rhs.m[3][1],
|
|
197
|
+
self.x * rhs.m[0][2] + self.y * rhs.m[1][2] + self.z * rhs.m[2][2] + self.w * rhs.m[3][2],
|
|
198
|
+
self.x * rhs.m[0][3] + self.y * rhs.m[1][3] + self.z * rhs.m[2][3] + self.w * rhs.m[3][3],
|
|
211
199
|
)
|
|
212
200
|
|
|
213
201
|
def __repr__(self):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|