Index: src/Common/NetTopologySuite/Noding/Octant.cs =================================================================== diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a --- src/Common/NetTopologySuite/Noding/Octant.cs (.../Octant.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9) +++ src/Common/NetTopologySuite/Noding/Octant.cs (.../Octant.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -2,7 +2,7 @@ using GeoAPI.Geometries; namespace GisSharpBlog.NetTopologySuite.Noding -{ +{ /// /// Octants in the Cartesian plane. /// Octants are numbered as follows: @@ -25,49 +25,49 @@ /// /// /// - Zero = 0, + Zero = 0, /// /// /// - One = 1, + One = 1, /// /// /// - Two = 2, + Two = 2, /// /// /// - Three = 3, + Three = 3, /// /// /// - Four = 4, + Four = 4, /// /// /// - Five = 5, + Five = 5, /// /// /// - Six = 6, + Six = 6, /// /// /// - Seven = 7, + Seven = 7, } /// /// Methods for computing and working with of the Cartesian plane. /// public static class Octant - { + { /// /// Returns the octant of a directed line segment (specified as x and y /// displacements, which cannot both be 0). @@ -78,7 +78,9 @@ public static Octants GetOctant(double dx, double dy) { if (dx == 0.0 && dy == 0.0) + { throw new ArgumentException("Cannot compute the octant for point ( " + dx + ", " + dy + " )"); + } double adx = Math.Abs(dx); double ady = Math.Abs(dy); @@ -88,33 +90,49 @@ if (dy >= 0) { if (adx >= ady) + { return Octants.Zero; + } else + { return Octants.One; + } } else // dy < 0 - { + { if (adx >= ady) + { return Octants.Seven; + } else + { return Octants.Six; + } } } else // dx < 0 - { + { if (dy >= 0) { if (adx >= ady) + { return Octants.Three; + } else + { return Octants.Two; + } } else // dy < 0 - { + { if (adx >= ady) + { return Octants.Four; + } else + { return Octants.Five; + } } } } @@ -130,8 +148,10 @@ double dx = p1.X - p0.X; double dy = p1.Y - p0.Y; if (dx == 0.0 && dy == 0.0) + { throw new ArgumentException("Cannot compute the octant for two identical points " + p0); + } return GetOctant(dx, dy); - } + } } -} +} \ No newline at end of file