Skip to content

Commit

Permalink
add test for LineXY.from_location_angle()
Browse files Browse the repository at this point in the history
  • Loading branch information
bbean23 committed Aug 9, 2024
1 parent 5d68883 commit fd22626
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions opencsp/common/lib/geometry/test/test_LineXY.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ def test_from_rho_theta(self):
self.assertAlmostEqual(l3.y_from_x(-1), 1)
self.assertAlmostEqual(l3.y_from_x(1), 1)

def test_from_location_angle(self):
# horizontal line
l1 = LineXY.from_location_angle(Vxy([1, 1]), 0)
self.assertAlmostEqual(l1.y_from_x(-1), 1)
self.assertAlmostEqual(l1.y_from_x(2), 1)

# 45-degree upward slope
l2 = LineXY.from_location_angle(Vxy([1, 1]), np.pi / 4)
self.assertAlmostEqual(l2.y_from_x(0), 0)
self.assertAlmostEqual(l2.y_from_x(2), 2)

# vertical line
l3 = LineXY.from_location_angle(Vxy([1, 1]), np.pi / 2)
self.assertAlmostEqual(l3.x_from_y(-1), 1)
self.assertAlmostEqual(l3.x_from_y(2), 1)

def test_y_from_x(self):
# Line y = -x
line = LineXY(1, 1, 0)
Expand Down

0 comments on commit fd22626

Please sign in to comment.