diff options
author | mdroe <mdroe@stsci.edu> | 2014-07-28 11:27:20 -0400 |
---|---|---|
committer | mdroe <mdroe@stsci.edu> | 2014-07-28 11:27:20 -0400 |
commit | b8263181dcfb4b01b4e6002a575f3373ae852847 (patch) | |
tree | 96b0b038b0048aae9aa36f294ca3792e0cf371e3 /stsci/sphere/test/test.py | |
parent | e0211e21f3db0bb27a04490d712dabe04c0fed26 (diff) | |
download | stsci.sphere-b8263181dcfb4b01b4e6002a575f3373ae852847.tar.gz |
Fix ordering of nodes in the trace routine so that the area calculation of polygons with cutlines is correct.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci.sphere/trunk@33584 fe389314-cf27-0410-b35b-8c050e845b92
Former-commit-id: 04c6e2875f229294be3c8592ba73d09457c42984
Diffstat (limited to 'stsci/sphere/test/test.py')
-rw-r--r-- | stsci/sphere/test/test.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/stsci/sphere/test/test.py b/stsci/sphere/test/test.py index 5ab7bbb..567ec1d 100644 --- a/stsci/sphere/test/test.py +++ b/stsci/sphere/test/test.py @@ -276,3 +276,34 @@ def test_area(): points = np.dstack((x, y, z))[0] poly = polygon.SphericalPolygon(points) calc_area = poly.area() + + +def test_fast_area(): + a = np.array( # Clockwise + [[ 0.35327617, 0.6351561 , -0.6868571 ], + [ 0.35295533, 0.63510299, -0.68707112], + [ 0.35298984, 0.63505081, -0.68710162], + [ 0.35331262, 0.63510039, -0.68688987], + [ 0.35327617, 0.6351561 , -0.6868571 ]]) + + b = np.array([ # Clockwise + [ 0.35331737, 0.6351013 , -0.68688658], + [ 0.3536442 , 0.63515101, -0.68667239], + [ 0.35360581, 0.63521041, -0.68663722], + [ 0.35328338, 0.63515742, -0.68685217], + [ 0.35328614, 0.63515318, -0.68685467], + [ 0.35328374, 0.63515279, -0.68685627], + [ 0.35331737, 0.6351013 , -0.68688658]]) + + c = np.array([ # Counterclockwise + [ 0.35331737, 0.6351013 , -0.68688658], + [ 0.35328374, 0.63515279, -0.68685627], + [ 0.35328614, 0.63515318, -0.68685467], + [ 0.35328338, 0.63515742, -0.68685217], + [ 0.35360581, 0.63521041, -0.68663722], + [ 0.3536442 , 0.63515101, -0.68667239], + [ 0.35331737, 0.6351013 , -0.68688658]]) + + assert graph.Graph._fast_area(a) > 0 + assert graph.Graph._fast_area(b) > 0 + assert graph.Graph._fast_area(c) < 0 |