add orthogonal projection
This commit is contained in:
parent
6faa0d7456
commit
71733c9099
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "matrixmania_brockmannti"
|
name = "matrixmania_brockmannti"
|
||||||
version = "0.1.1"
|
version = "0.1.3"
|
||||||
description = "MatrixMania: Simple linear algebra functions for teaching (matmul, transpose, rot_2D)."
|
description = "MatrixMania: Simple linear algebra functions for teaching (matmul, transpose, rot_2D)."
|
||||||
authors = [
|
authors = [
|
||||||
{ name="Tilo Brockmann", email="brockmannti93157@th-nuernberg.de" }
|
{ name="Tilo Brockmann", email="brockmannti93157@th-nuernberg.de" }
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
from typing import List
|
from typing import List, Tuple
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
import pygame
|
||||||
|
|
||||||
|
|
||||||
def product(factors: List[int]) -> int:
|
def product(factors: List[int]) -> int:
|
||||||
"""
|
"""
|
||||||
@ -113,3 +115,7 @@ def rot_3D(angle: float, axis: str) -> List[List[float]]:
|
|||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
raise ValueError("axis must be either x, y or z")
|
raise ValueError("axis must be either x, y or z")
|
||||||
|
|
||||||
|
|
||||||
|
def project_ortho(point: Tuple[float, float, float], scale: float = 1) -> Tuple[float, float]:
|
||||||
|
return point[0] * scale, point[1] * scale
|
||||||
14
test/test_matrixmania/test_projection.py
Normal file
14
test/test_matrixmania/test_projection.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import pytest
|
||||||
|
from src.matrixmania.compute import project_ortho
|
||||||
|
|
||||||
|
def test_projection():
|
||||||
|
point = (1.0, 2.0, 3.0)
|
||||||
|
expected = (1.0, 2.0)
|
||||||
|
|
||||||
|
assert project_ortho(point) == expected
|
||||||
|
|
||||||
|
def test_projection_with_scale():
|
||||||
|
point = (1.0, 2.0, 3.0)
|
||||||
|
expected = (100.0, 200.0)
|
||||||
|
|
||||||
|
assert project_ortho(point, 100) == expected
|
||||||
Loading…
x
Reference in New Issue
Block a user