summaryrefslogtreecommitdiff
path: root/lib/test/test.py
diff options
context:
space:
mode:
authormdroe <mdroe@stsci.edu>2012-06-05 13:30:37 -0400
committermdroe <mdroe@stsci.edu>2012-06-05 13:30:37 -0400
commit67962ed392034cc221e928b9769e7bf98c9f6afd (patch)
treea6c73085f3eac19a8080063fb9986ce1f10f30cf /lib/test/test.py
parentf502335a1a9121eeaa8bd2e06adae49c5408830a (diff)
downloadstsci.sphere-67962ed392034cc221e928b9769e7bf98c9f6afd.tar.gz
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
Diffstat (limited to 'lib/test/test.py')
-rw-r--r--lib/test/test.py15
1 files changed, 15 insertions, 0 deletions
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()