Skip to content

Commit

Permalink
[python] Add tests for geometry functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Sep 10, 2024
1 parent 2395704 commit dc8eb2f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/python/test/test_geometry_math.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import numpy as np

from pffdtd.geometry.math import find_third_vertex, transform_point


def test_find_third_vertex():
v = find_third_vertex([0, 0, 0], [2, 0, 0])
assert np.allclose(v, ([1, +1.73205081, 0], [1, -1.73205081, 0]))

v = find_third_vertex([0, 0, 1.2], [3, 0, 1.2])
assert np.allclose(v, ([1.5, +2.59807621, 1.2], [1.5, -2.59807621, 1.2]))


def test_transform_point():
p = transform_point([0, 0, 0], [1, 1, 1], [0, 0, 0], [0, 0, 0])
assert np.allclose(p, [0, 0, 0])

p = transform_point([1, 2, 3], [1, 1, 1], [0, 0, 0], [0, 0, 0])
assert np.allclose(p, [1, 2, 3])

p = transform_point([1, 2, 3], [1, 1, 1], [0, 0, 0], [-1, -2, -4])
assert np.allclose(p, [0, 0, -1])

0 comments on commit dc8eb2f

Please sign in to comment.