From 67962ed392034cc221e928b9769e7bf98c9f6afd Mon Sep 17 00:00:00 2001 From: mdroe Date: Tue, 5 Jun 2012 17:30:37 +0000 Subject: Some tweaks to the area calculation. git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/branches/sphere@17202 fe389314-cf27-0410-b35b-8c050e845b92 Former-commit-id: 07101e1f3d5f37ea231b64b33283b8864ac1a0fc --- lib/test/test.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/test/test.py') diff --git a/lib/test/test.py b/lib/test/test.py index 34b5afa..b551090 100644 --- a/lib/test/test.py +++ b/lib/test/test.py @@ -260,3 +260,18 @@ def test_cone(): ra = random.randrange(-180, 180) dec = random.randrange(20, 90) cone = polygon.SphericalPolygon.from_cone(ra, dec, 8, steps=64) + + +def test_area(): + triangles = [ + ([[90, 0], [0, -45], [0, 45], [90, 0]], np.pi * 0.5), + ([[90, 0], [0, -22.5], [0, 22.5], [90, 0]], np.pi * 0.25), + ([[90, 0], [0, -11.25], [0, 11.25], [90, 0]], np.pi * 0.125) + ] + + for tri, area in triangles: + tri = np.array(tri) + x, y, z = vector.radec_to_vector(tri[:,1], tri[:,0]) + points = np.dstack((x, y, z))[0] + poly = polygon.SphericalPolygon(points) + calc_area = poly.area() -- cgit