private void InitBound() { // The bounding rectangle of a loop is not necessarily the same as the // bounding rectangle of its vertices. First, the loop may wrap entirely // around the sphere (e.g. a loop that defines two revolutions of a // candy-cane stripe). Second, the loop may include one or both poles. // Note that a small clockwise loop near the equator contains both poles. var bounder = new RectBounder(); for (var i = 0; i <= NumVertices; ++i) { bounder.AddPoint(Vertex(i)); } var b = bounder.Bound; // Note that we need to initialize bound with a temporary value since // contains() does a bounding rectangle check before doing anything else. _bound = S2LatLngRect.Full; if (Contains(new S2Point(0, 0, 1))) { b = new S2LatLngRect(new R1Interval(b.Lat.Lo, S2.PiOver2), S1Interval.Full); } // If a loop contains the south pole, then either it wraps entirely // around the sphere (full longitude range), or it also contains the // north pole in which case b.lng().isFull() due to the test above. if (b.Lng.IsFull && Contains(new S2Point(0, 0, -1))) { b = new S2LatLngRect(new R1Interval(-S2.PiOver2, b.Lat.Hi), b.Lng); } _bound = b; }
private S2LatLngRect getEdgeBound(double x1, double y1, double z1, double x2, double y2, double z2) { var bounder = new RectBounder(); var p1 = S2Point.Normalize(new S2Point(x1, y1, z1)); var p2 = S2Point.Normalize(new S2Point(x2, y2, z2)); bounder.AddPoint(p1); bounder.AddPoint(p2); return bounder.Bound; }