Add project_ortho() function and tests

This commit is contained in:
BrSh31
2025-11-11 16:08:47 +01:00
parent 7e0c77642d
commit 528cd9ff7a
9 changed files with 27 additions and 1 deletions
Binary file not shown.
Binary file not shown.
+13 -1
View File
@@ -1,6 +1,7 @@
from typing import List
import math
from tabulate import tabulate
from typing import Tuple
def matmul(mat1: List[List[int]], mat2: List[List[int]]) -> List[List[int]]:
"""
@@ -119,6 +120,18 @@ def rot_3D(angle: float, axis: str) -> List[List[float]]:
else:
raise ValueError("Axis must be 'x', 'y', or 'z'.")
def project_ortho(point: Tuple[float, float, float], scale: float = 1) -> Tuple[float, float]:
"""
Retruns a 2d point with optional scaling
ignores the z axis and if scaling needed scales the 2d point
:param point: Coordinates of a 3d point
:param scale: scaling factor (else 1)
:return: A 2d point
"""
return scale * point[0], scale * point[1]
def main():
# Test matrix multiplication
@@ -150,7 +163,6 @@ def main():
print("Matrix A:")
print(tabulate(matrix_a))
if __name__ == "__main__":
main()