Release NaraMotion v0.26.0: Structure of Arrays (SoA), Path Arena Allocator, Uniform Grid Indexing, Dual-Buffer Rendering & Centroid Spring Pop-in
b516e00 verified Download tests/test_matrix.py from ArifiIslam/NaraMotion: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/ArifiIslam/NaraMotion/resolve/main/tests/test_matrix.py
- Command line
-
hf download hf://ArifiIslam/NaraMotion/tests/test_matrix.py
-
curl -L -o test_matrix.py https://huggingface.co/ArifiIslam/NaraMotion/resolve/main/tests/test_matrix.py
1 kB
| import math | |
| import pytest | |
| from naramotion import Matrix2D, Point | |
| def test_matrix_identity(): | |
| m = Matrix2D.identity() | |
| p = m.map_point(10, 20) | |
| assert p.x == 10.0 | |
| assert p.y == 20.0 | |
| def test_matrix_translation(): | |
| m = Matrix2D.make_translation(50, 100) | |
| p = m.map_point(10, 20) | |
| assert p.x == 60.0 | |
| assert p.y == 120.0 | |
| def test_matrix_scaling(): | |
| m = Matrix2D.make_scaling(2.0, 3.0) | |
| p = m.map_point(10, 20) | |
| assert p.x == 20.0 | |
| assert p.y == 60.0 | |
| def test_matrix_rotation(): | |
| m = Matrix2D.make_rotation_deg(90.0) | |
| p = m.map_point(10, 0) | |
| assert abs(p.x - 0.0) < 1e-5 | |
| assert abs(p.y - 10.0) < 1e-5 | |
| def test_matrix_inversion(): | |
| m = Matrix2D.make_translation(30, 40) | |
| m.scale(2.0, 2.0) | |
| inv = m.invert() | |
| p = Point(10, 20) | |
| mapped = m.map_point(p.x, p.y) | |
| unmapped = inv.map_point(mapped.x, mapped.y) | |
| assert abs(unmapped.x - p.x) < 1e-5 | |
| assert abs(unmapped.y - p.y) < 1e-5 | |