id
int32 0
167k
| repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
150,000 | golang/geo | s2/rect.go | PolarClosure | func (r Rect) PolarClosure() Rect {
if r.Lat.Lo == -math.Pi/2 || r.Lat.Hi == math.Pi/2 {
return Rect{r.Lat, s1.FullInterval()}
}
return r
} | go | func (r Rect) PolarClosure() Rect {
if r.Lat.Lo == -math.Pi/2 || r.Lat.Hi == math.Pi/2 {
return Rect{r.Lat, s1.FullInterval()}
}
return r
} | [
"func",
"(",
"r",
"Rect",
")",
"PolarClosure",
"(",
")",
"Rect",
"{",
"if",
"r",
".",
"Lat",
".",
"Lo",
"==",
"-",
"math",
".",
"Pi",
"/",
"2",
"||",
"r",
".",
"Lat",
".",
"Hi",
"==",
"math",
".",
"Pi",
"/",
"2",
"{",
"return",
"Rect",
"{",
"r",
".",
"Lat",
",",
"s1",
".",
"FullInterval",
"(",
")",
"}",
"\n",
"}",
"\n",
"return",
"r",
"\n",
"}"
] | // PolarClosure returns the rectangle unmodified if it does not include either pole.
// If it includes either pole, PolarClosure returns an expansion of the rectangle along
// the longitudinal range to include all possible representations of the contained poles. | [
"PolarClosure",
"returns",
"the",
"rectangle",
"unmodified",
"if",
"it",
"does",
"not",
"include",
"either",
"pole",
".",
"If",
"it",
"includes",
"either",
"pole",
"PolarClosure",
"returns",
"an",
"expansion",
"of",
"the",
"rectangle",
"along",
"the",
"longitudinal",
"range",
"to",
"include",
"all",
"possible",
"representations",
"of",
"the",
"contained",
"poles",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L189-L194 |
150,001 | golang/geo | s2/rect.go | Union | func (r Rect) Union(other Rect) Rect {
return Rect{
Lat: r.Lat.Union(other.Lat),
Lng: r.Lng.Union(other.Lng),
}
} | go | func (r Rect) Union(other Rect) Rect {
return Rect{
Lat: r.Lat.Union(other.Lat),
Lng: r.Lng.Union(other.Lng),
}
} | [
"func",
"(",
"r",
"Rect",
")",
"Union",
"(",
"other",
"Rect",
")",
"Rect",
"{",
"return",
"Rect",
"{",
"Lat",
":",
"r",
".",
"Lat",
".",
"Union",
"(",
"other",
".",
"Lat",
")",
",",
"Lng",
":",
"r",
".",
"Lng",
".",
"Union",
"(",
"other",
".",
"Lng",
")",
",",
"}",
"\n",
"}"
] | // Union returns the smallest Rect containing the union of this rectangle and the given rectangle. | [
"Union",
"returns",
"the",
"smallest",
"Rect",
"containing",
"the",
"union",
"of",
"this",
"rectangle",
"and",
"the",
"given",
"rectangle",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L197-L202 |
150,002 | golang/geo | s2/rect.go | Intersection | func (r Rect) Intersection(other Rect) Rect {
lat := r.Lat.Intersection(other.Lat)
lng := r.Lng.Intersection(other.Lng)
if lat.IsEmpty() || lng.IsEmpty() {
return EmptyRect()
}
return Rect{lat, lng}
} | go | func (r Rect) Intersection(other Rect) Rect {
lat := r.Lat.Intersection(other.Lat)
lng := r.Lng.Intersection(other.Lng)
if lat.IsEmpty() || lng.IsEmpty() {
return EmptyRect()
}
return Rect{lat, lng}
} | [
"func",
"(",
"r",
"Rect",
")",
"Intersection",
"(",
"other",
"Rect",
")",
"Rect",
"{",
"lat",
":=",
"r",
".",
"Lat",
".",
"Intersection",
"(",
"other",
".",
"Lat",
")",
"\n",
"lng",
":=",
"r",
".",
"Lng",
".",
"Intersection",
"(",
"other",
".",
"Lng",
")",
"\n\n",
"if",
"lat",
".",
"IsEmpty",
"(",
")",
"||",
"lng",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"EmptyRect",
"(",
")",
"\n",
"}",
"\n",
"return",
"Rect",
"{",
"lat",
",",
"lng",
"}",
"\n",
"}"
] | // Intersection returns the smallest rectangle containing the intersection of
// this rectangle and the given rectangle. Note that the region of intersection
// may consist of two disjoint rectangles, in which case a single rectangle
// spanning both of them is returned. | [
"Intersection",
"returns",
"the",
"smallest",
"rectangle",
"containing",
"the",
"intersection",
"of",
"this",
"rectangle",
"and",
"the",
"given",
"rectangle",
".",
"Note",
"that",
"the",
"region",
"of",
"intersection",
"may",
"consist",
"of",
"two",
"disjoint",
"rectangles",
"in",
"which",
"case",
"a",
"single",
"rectangle",
"spanning",
"both",
"of",
"them",
"is",
"returned",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L208-L216 |
150,003 | golang/geo | s2/rect.go | Intersects | func (r Rect) Intersects(other Rect) bool {
return r.Lat.Intersects(other.Lat) && r.Lng.Intersects(other.Lng)
} | go | func (r Rect) Intersects(other Rect) bool {
return r.Lat.Intersects(other.Lat) && r.Lng.Intersects(other.Lng)
} | [
"func",
"(",
"r",
"Rect",
")",
"Intersects",
"(",
"other",
"Rect",
")",
"bool",
"{",
"return",
"r",
".",
"Lat",
".",
"Intersects",
"(",
"other",
".",
"Lat",
")",
"&&",
"r",
".",
"Lng",
".",
"Intersects",
"(",
"other",
".",
"Lng",
")",
"\n",
"}"
] | // Intersects reports whether this rectangle and the other have any points in common. | [
"Intersects",
"reports",
"whether",
"this",
"rectangle",
"and",
"the",
"other",
"have",
"any",
"points",
"in",
"common",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L219-L221 |
150,004 | golang/geo | s2/rect.go | CapBound | func (r Rect) CapBound() Cap {
// We consider two possible bounding caps, one whose axis passes
// through the center of the lat-long rectangle and one whose axis
// is the north or south pole. We return the smaller of the two caps.
if r.IsEmpty() {
return EmptyCap()
}
var poleZ, poleAngle float64
if r.Lat.Hi+r.Lat.Lo < 0 {
// South pole axis yields smaller cap.
poleZ = -1
poleAngle = math.Pi/2 + r.Lat.Hi
} else {
poleZ = 1
poleAngle = math.Pi/2 - r.Lat.Lo
}
poleCap := CapFromCenterAngle(Point{r3.Vector{0, 0, poleZ}}, s1.Angle(poleAngle)*s1.Radian)
// For bounding rectangles that span 180 degrees or less in longitude, the
// maximum cap size is achieved at one of the rectangle vertices. For
// rectangles that are larger than 180 degrees, we punt and always return a
// bounding cap centered at one of the two poles.
if math.Remainder(r.Lng.Hi-r.Lng.Lo, 2*math.Pi) >= 0 && r.Lng.Hi-r.Lng.Lo < 2*math.Pi {
midCap := CapFromPoint(PointFromLatLng(r.Center())).AddPoint(PointFromLatLng(r.Lo())).AddPoint(PointFromLatLng(r.Hi()))
if midCap.Height() < poleCap.Height() {
return midCap
}
}
return poleCap
} | go | func (r Rect) CapBound() Cap {
// We consider two possible bounding caps, one whose axis passes
// through the center of the lat-long rectangle and one whose axis
// is the north or south pole. We return the smaller of the two caps.
if r.IsEmpty() {
return EmptyCap()
}
var poleZ, poleAngle float64
if r.Lat.Hi+r.Lat.Lo < 0 {
// South pole axis yields smaller cap.
poleZ = -1
poleAngle = math.Pi/2 + r.Lat.Hi
} else {
poleZ = 1
poleAngle = math.Pi/2 - r.Lat.Lo
}
poleCap := CapFromCenterAngle(Point{r3.Vector{0, 0, poleZ}}, s1.Angle(poleAngle)*s1.Radian)
// For bounding rectangles that span 180 degrees or less in longitude, the
// maximum cap size is achieved at one of the rectangle vertices. For
// rectangles that are larger than 180 degrees, we punt and always return a
// bounding cap centered at one of the two poles.
if math.Remainder(r.Lng.Hi-r.Lng.Lo, 2*math.Pi) >= 0 && r.Lng.Hi-r.Lng.Lo < 2*math.Pi {
midCap := CapFromPoint(PointFromLatLng(r.Center())).AddPoint(PointFromLatLng(r.Lo())).AddPoint(PointFromLatLng(r.Hi()))
if midCap.Height() < poleCap.Height() {
return midCap
}
}
return poleCap
} | [
"func",
"(",
"r",
"Rect",
")",
"CapBound",
"(",
")",
"Cap",
"{",
"// We consider two possible bounding caps, one whose axis passes",
"// through the center of the lat-long rectangle and one whose axis",
"// is the north or south pole. We return the smaller of the two caps.",
"if",
"r",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"EmptyCap",
"(",
")",
"\n",
"}",
"\n\n",
"var",
"poleZ",
",",
"poleAngle",
"float64",
"\n",
"if",
"r",
".",
"Lat",
".",
"Hi",
"+",
"r",
".",
"Lat",
".",
"Lo",
"<",
"0",
"{",
"// South pole axis yields smaller cap.",
"poleZ",
"=",
"-",
"1",
"\n",
"poleAngle",
"=",
"math",
".",
"Pi",
"/",
"2",
"+",
"r",
".",
"Lat",
".",
"Hi",
"\n",
"}",
"else",
"{",
"poleZ",
"=",
"1",
"\n",
"poleAngle",
"=",
"math",
".",
"Pi",
"/",
"2",
"-",
"r",
".",
"Lat",
".",
"Lo",
"\n",
"}",
"\n",
"poleCap",
":=",
"CapFromCenterAngle",
"(",
"Point",
"{",
"r3",
".",
"Vector",
"{",
"0",
",",
"0",
",",
"poleZ",
"}",
"}",
",",
"s1",
".",
"Angle",
"(",
"poleAngle",
")",
"*",
"s1",
".",
"Radian",
")",
"\n\n",
"// For bounding rectangles that span 180 degrees or less in longitude, the",
"// maximum cap size is achieved at one of the rectangle vertices. For",
"// rectangles that are larger than 180 degrees, we punt and always return a",
"// bounding cap centered at one of the two poles.",
"if",
"math",
".",
"Remainder",
"(",
"r",
".",
"Lng",
".",
"Hi",
"-",
"r",
".",
"Lng",
".",
"Lo",
",",
"2",
"*",
"math",
".",
"Pi",
")",
">=",
"0",
"&&",
"r",
".",
"Lng",
".",
"Hi",
"-",
"r",
".",
"Lng",
".",
"Lo",
"<",
"2",
"*",
"math",
".",
"Pi",
"{",
"midCap",
":=",
"CapFromPoint",
"(",
"PointFromLatLng",
"(",
"r",
".",
"Center",
"(",
")",
")",
")",
".",
"AddPoint",
"(",
"PointFromLatLng",
"(",
"r",
".",
"Lo",
"(",
")",
")",
")",
".",
"AddPoint",
"(",
"PointFromLatLng",
"(",
"r",
".",
"Hi",
"(",
")",
")",
")",
"\n",
"if",
"midCap",
".",
"Height",
"(",
")",
"<",
"poleCap",
".",
"Height",
"(",
")",
"{",
"return",
"midCap",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"poleCap",
"\n",
"}"
] | // CapBound returns a cap that countains Rect. | [
"CapBound",
"returns",
"a",
"cap",
"that",
"countains",
"Rect",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L224-L255 |
150,005 | golang/geo | s2/rect.go | Contains | func (r Rect) Contains(other Rect) bool {
return r.Lat.ContainsInterval(other.Lat) && r.Lng.ContainsInterval(other.Lng)
} | go | func (r Rect) Contains(other Rect) bool {
return r.Lat.ContainsInterval(other.Lat) && r.Lng.ContainsInterval(other.Lng)
} | [
"func",
"(",
"r",
"Rect",
")",
"Contains",
"(",
"other",
"Rect",
")",
"bool",
"{",
"return",
"r",
".",
"Lat",
".",
"ContainsInterval",
"(",
"other",
".",
"Lat",
")",
"&&",
"r",
".",
"Lng",
".",
"ContainsInterval",
"(",
"other",
".",
"Lng",
")",
"\n",
"}"
] | // Contains reports whether this Rect contains the other Rect. | [
"Contains",
"reports",
"whether",
"this",
"Rect",
"contains",
"the",
"other",
"Rect",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L263-L265 |
150,006 | golang/geo | s2/rect.go | ContainsCell | func (r Rect) ContainsCell(c Cell) bool {
// A latitude-longitude rectangle contains a cell if and only if it contains
// the cell's bounding rectangle. This test is exact from a mathematical
// point of view, assuming that the bounds returned by Cell.RectBound()
// are tight. However, note that there can be a loss of precision when
// converting between representations -- for example, if an s2.Cell is
// converted to a polygon, the polygon's bounding rectangle may not contain
// the cell's bounding rectangle. This has some slightly unexpected side
// effects; for instance, if one creates an s2.Polygon from an s2.Cell, the
// polygon will contain the cell, but the polygon's bounding box will not.
return r.Contains(c.RectBound())
} | go | func (r Rect) ContainsCell(c Cell) bool {
// A latitude-longitude rectangle contains a cell if and only if it contains
// the cell's bounding rectangle. This test is exact from a mathematical
// point of view, assuming that the bounds returned by Cell.RectBound()
// are tight. However, note that there can be a loss of precision when
// converting between representations -- for example, if an s2.Cell is
// converted to a polygon, the polygon's bounding rectangle may not contain
// the cell's bounding rectangle. This has some slightly unexpected side
// effects; for instance, if one creates an s2.Polygon from an s2.Cell, the
// polygon will contain the cell, but the polygon's bounding box will not.
return r.Contains(c.RectBound())
} | [
"func",
"(",
"r",
"Rect",
")",
"ContainsCell",
"(",
"c",
"Cell",
")",
"bool",
"{",
"// A latitude-longitude rectangle contains a cell if and only if it contains",
"// the cell's bounding rectangle. This test is exact from a mathematical",
"// point of view, assuming that the bounds returned by Cell.RectBound()",
"// are tight. However, note that there can be a loss of precision when",
"// converting between representations -- for example, if an s2.Cell is",
"// converted to a polygon, the polygon's bounding rectangle may not contain",
"// the cell's bounding rectangle. This has some slightly unexpected side",
"// effects; for instance, if one creates an s2.Polygon from an s2.Cell, the",
"// polygon will contain the cell, but the polygon's bounding box will not.",
"return",
"r",
".",
"Contains",
"(",
"c",
".",
"RectBound",
"(",
")",
")",
"\n",
"}"
] | // ContainsCell reports whether the given Cell is contained by this Rect. | [
"ContainsCell",
"reports",
"whether",
"the",
"given",
"Cell",
"is",
"contained",
"by",
"this",
"Rect",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L268-L279 |
150,007 | golang/geo | s2/rect.go | ContainsLatLng | func (r Rect) ContainsLatLng(ll LatLng) bool {
if !ll.IsValid() {
return false
}
return r.Lat.Contains(ll.Lat.Radians()) && r.Lng.Contains(ll.Lng.Radians())
} | go | func (r Rect) ContainsLatLng(ll LatLng) bool {
if !ll.IsValid() {
return false
}
return r.Lat.Contains(ll.Lat.Radians()) && r.Lng.Contains(ll.Lng.Radians())
} | [
"func",
"(",
"r",
"Rect",
")",
"ContainsLatLng",
"(",
"ll",
"LatLng",
")",
"bool",
"{",
"if",
"!",
"ll",
".",
"IsValid",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"r",
".",
"Lat",
".",
"Contains",
"(",
"ll",
".",
"Lat",
".",
"Radians",
"(",
")",
")",
"&&",
"r",
".",
"Lng",
".",
"Contains",
"(",
"ll",
".",
"Lng",
".",
"Radians",
"(",
")",
")",
"\n",
"}"
] | // ContainsLatLng reports whether the given LatLng is within the Rect. | [
"ContainsLatLng",
"reports",
"whether",
"the",
"given",
"LatLng",
"is",
"within",
"the",
"Rect",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L282-L287 |
150,008 | golang/geo | s2/rect.go | ContainsPoint | func (r Rect) ContainsPoint(p Point) bool {
return r.ContainsLatLng(LatLngFromPoint(p))
} | go | func (r Rect) ContainsPoint(p Point) bool {
return r.ContainsLatLng(LatLngFromPoint(p))
} | [
"func",
"(",
"r",
"Rect",
")",
"ContainsPoint",
"(",
"p",
"Point",
")",
"bool",
"{",
"return",
"r",
".",
"ContainsLatLng",
"(",
"LatLngFromPoint",
"(",
"p",
")",
")",
"\n",
"}"
] | // ContainsPoint reports whether the given Point is within the Rect. | [
"ContainsPoint",
"reports",
"whether",
"the",
"given",
"Point",
"is",
"within",
"the",
"Rect",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L290-L292 |
150,009 | golang/geo | s2/rect.go | intersectsLatEdge | func intersectsLatEdge(a, b Point, lat s1.Angle, lng s1.Interval) bool {
// Unfortunately, lines of constant latitude are curves on
// the sphere. They can intersect a straight edge in 0, 1, or 2 points.
// First, compute the normal to the plane AB that points vaguely north.
z := Point{a.PointCross(b).Normalize()}
if z.Z < 0 {
z = Point{z.Mul(-1)}
}
// Extend this to an orthonormal frame (x,y,z) where x is the direction
// where the great circle through AB achieves its maximium latitude.
y := Point{z.PointCross(PointFromCoords(0, 0, 1)).Normalize()}
x := y.Cross(z.Vector)
// Compute the angle "theta" from the x-axis (in the x-y plane defined
// above) where the great circle intersects the given line of latitude.
sinLat := math.Sin(float64(lat))
if math.Abs(sinLat) >= x.Z {
// The great circle does not reach the given latitude.
return false
}
cosTheta := sinLat / x.Z
sinTheta := math.Sqrt(1 - cosTheta*cosTheta)
theta := math.Atan2(sinTheta, cosTheta)
// The candidate intersection points are located +/- theta in the x-y
// plane. For an intersection to be valid, we need to check that the
// intersection point is contained in the interior of the edge AB and
// also that it is contained within the given longitude interval "lng".
// Compute the range of theta values spanned by the edge AB.
abTheta := s1.IntervalFromPointPair(
math.Atan2(a.Dot(y.Vector), a.Dot(x)),
math.Atan2(b.Dot(y.Vector), b.Dot(x)))
if abTheta.Contains(theta) {
// Check if the intersection point is also in the given lng interval.
isect := x.Mul(cosTheta).Add(y.Mul(sinTheta))
if lng.Contains(math.Atan2(isect.Y, isect.X)) {
return true
}
}
if abTheta.Contains(-theta) {
// Check if the other intersection point is also in the given lng interval.
isect := x.Mul(cosTheta).Sub(y.Mul(sinTheta))
if lng.Contains(math.Atan2(isect.Y, isect.X)) {
return true
}
}
return false
} | go | func intersectsLatEdge(a, b Point, lat s1.Angle, lng s1.Interval) bool {
// Unfortunately, lines of constant latitude are curves on
// the sphere. They can intersect a straight edge in 0, 1, or 2 points.
// First, compute the normal to the plane AB that points vaguely north.
z := Point{a.PointCross(b).Normalize()}
if z.Z < 0 {
z = Point{z.Mul(-1)}
}
// Extend this to an orthonormal frame (x,y,z) where x is the direction
// where the great circle through AB achieves its maximium latitude.
y := Point{z.PointCross(PointFromCoords(0, 0, 1)).Normalize()}
x := y.Cross(z.Vector)
// Compute the angle "theta" from the x-axis (in the x-y plane defined
// above) where the great circle intersects the given line of latitude.
sinLat := math.Sin(float64(lat))
if math.Abs(sinLat) >= x.Z {
// The great circle does not reach the given latitude.
return false
}
cosTheta := sinLat / x.Z
sinTheta := math.Sqrt(1 - cosTheta*cosTheta)
theta := math.Atan2(sinTheta, cosTheta)
// The candidate intersection points are located +/- theta in the x-y
// plane. For an intersection to be valid, we need to check that the
// intersection point is contained in the interior of the edge AB and
// also that it is contained within the given longitude interval "lng".
// Compute the range of theta values spanned by the edge AB.
abTheta := s1.IntervalFromPointPair(
math.Atan2(a.Dot(y.Vector), a.Dot(x)),
math.Atan2(b.Dot(y.Vector), b.Dot(x)))
if abTheta.Contains(theta) {
// Check if the intersection point is also in the given lng interval.
isect := x.Mul(cosTheta).Add(y.Mul(sinTheta))
if lng.Contains(math.Atan2(isect.Y, isect.X)) {
return true
}
}
if abTheta.Contains(-theta) {
// Check if the other intersection point is also in the given lng interval.
isect := x.Mul(cosTheta).Sub(y.Mul(sinTheta))
if lng.Contains(math.Atan2(isect.Y, isect.X)) {
return true
}
}
return false
} | [
"func",
"intersectsLatEdge",
"(",
"a",
",",
"b",
"Point",
",",
"lat",
"s1",
".",
"Angle",
",",
"lng",
"s1",
".",
"Interval",
")",
"bool",
"{",
"// Unfortunately, lines of constant latitude are curves on",
"// the sphere. They can intersect a straight edge in 0, 1, or 2 points.",
"// First, compute the normal to the plane AB that points vaguely north.",
"z",
":=",
"Point",
"{",
"a",
".",
"PointCross",
"(",
"b",
")",
".",
"Normalize",
"(",
")",
"}",
"\n",
"if",
"z",
".",
"Z",
"<",
"0",
"{",
"z",
"=",
"Point",
"{",
"z",
".",
"Mul",
"(",
"-",
"1",
")",
"}",
"\n",
"}",
"\n\n",
"// Extend this to an orthonormal frame (x,y,z) where x is the direction",
"// where the great circle through AB achieves its maximium latitude.",
"y",
":=",
"Point",
"{",
"z",
".",
"PointCross",
"(",
"PointFromCoords",
"(",
"0",
",",
"0",
",",
"1",
")",
")",
".",
"Normalize",
"(",
")",
"}",
"\n",
"x",
":=",
"y",
".",
"Cross",
"(",
"z",
".",
"Vector",
")",
"\n\n",
"// Compute the angle \"theta\" from the x-axis (in the x-y plane defined",
"// above) where the great circle intersects the given line of latitude.",
"sinLat",
":=",
"math",
".",
"Sin",
"(",
"float64",
"(",
"lat",
")",
")",
"\n",
"if",
"math",
".",
"Abs",
"(",
"sinLat",
")",
">=",
"x",
".",
"Z",
"{",
"// The great circle does not reach the given latitude.",
"return",
"false",
"\n",
"}",
"\n\n",
"cosTheta",
":=",
"sinLat",
"/",
"x",
".",
"Z",
"\n",
"sinTheta",
":=",
"math",
".",
"Sqrt",
"(",
"1",
"-",
"cosTheta",
"*",
"cosTheta",
")",
"\n",
"theta",
":=",
"math",
".",
"Atan2",
"(",
"sinTheta",
",",
"cosTheta",
")",
"\n\n",
"// The candidate intersection points are located +/- theta in the x-y",
"// plane. For an intersection to be valid, we need to check that the",
"// intersection point is contained in the interior of the edge AB and",
"// also that it is contained within the given longitude interval \"lng\".",
"// Compute the range of theta values spanned by the edge AB.",
"abTheta",
":=",
"s1",
".",
"IntervalFromPointPair",
"(",
"math",
".",
"Atan2",
"(",
"a",
".",
"Dot",
"(",
"y",
".",
"Vector",
")",
",",
"a",
".",
"Dot",
"(",
"x",
")",
")",
",",
"math",
".",
"Atan2",
"(",
"b",
".",
"Dot",
"(",
"y",
".",
"Vector",
")",
",",
"b",
".",
"Dot",
"(",
"x",
")",
")",
")",
"\n\n",
"if",
"abTheta",
".",
"Contains",
"(",
"theta",
")",
"{",
"// Check if the intersection point is also in the given lng interval.",
"isect",
":=",
"x",
".",
"Mul",
"(",
"cosTheta",
")",
".",
"Add",
"(",
"y",
".",
"Mul",
"(",
"sinTheta",
")",
")",
"\n",
"if",
"lng",
".",
"Contains",
"(",
"math",
".",
"Atan2",
"(",
"isect",
".",
"Y",
",",
"isect",
".",
"X",
")",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"abTheta",
".",
"Contains",
"(",
"-",
"theta",
")",
"{",
"// Check if the other intersection point is also in the given lng interval.",
"isect",
":=",
"x",
".",
"Mul",
"(",
"cosTheta",
")",
".",
"Sub",
"(",
"y",
".",
"Mul",
"(",
"sinTheta",
")",
")",
"\n",
"if",
"lng",
".",
"Contains",
"(",
"math",
".",
"Atan2",
"(",
"isect",
".",
"Y",
",",
"isect",
".",
"X",
")",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // intersectsLatEdge reports whether the edge AB intersects the given edge of constant
// latitude. Requires the points to have unit length. | [
"intersectsLatEdge",
"reports",
"whether",
"the",
"edge",
"AB",
"intersects",
"the",
"given",
"edge",
"of",
"constant",
"latitude",
".",
"Requires",
"the",
"points",
"to",
"have",
"unit",
"length",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L301-L354 |
150,010 | golang/geo | s2/rect.go | intersectsLngEdge | func intersectsLngEdge(a, b Point, lat r1.Interval, lng s1.Angle) bool {
// The nice thing about edges of constant longitude is that
// they are straight lines on the sphere (geodesics).
return CrossingSign(a, b, PointFromLatLng(LatLng{s1.Angle(lat.Lo), lng}),
PointFromLatLng(LatLng{s1.Angle(lat.Hi), lng})) == Cross
} | go | func intersectsLngEdge(a, b Point, lat r1.Interval, lng s1.Angle) bool {
// The nice thing about edges of constant longitude is that
// they are straight lines on the sphere (geodesics).
return CrossingSign(a, b, PointFromLatLng(LatLng{s1.Angle(lat.Lo), lng}),
PointFromLatLng(LatLng{s1.Angle(lat.Hi), lng})) == Cross
} | [
"func",
"intersectsLngEdge",
"(",
"a",
",",
"b",
"Point",
",",
"lat",
"r1",
".",
"Interval",
",",
"lng",
"s1",
".",
"Angle",
")",
"bool",
"{",
"// The nice thing about edges of constant longitude is that",
"// they are straight lines on the sphere (geodesics).",
"return",
"CrossingSign",
"(",
"a",
",",
"b",
",",
"PointFromLatLng",
"(",
"LatLng",
"{",
"s1",
".",
"Angle",
"(",
"lat",
".",
"Lo",
")",
",",
"lng",
"}",
")",
",",
"PointFromLatLng",
"(",
"LatLng",
"{",
"s1",
".",
"Angle",
"(",
"lat",
".",
"Hi",
")",
",",
"lng",
"}",
")",
")",
"==",
"Cross",
"\n",
"}"
] | // intersectsLngEdge reports whether the edge AB intersects the given edge of constant
// longitude. Requires the points to have unit length. | [
"intersectsLngEdge",
"reports",
"whether",
"the",
"edge",
"AB",
"intersects",
"the",
"given",
"edge",
"of",
"constant",
"longitude",
".",
"Requires",
"the",
"points",
"to",
"have",
"unit",
"length",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L358-L363 |
150,011 | golang/geo | s2/rect.go | IntersectsCell | func (r Rect) IntersectsCell(c Cell) bool {
// First we eliminate the cases where one region completely contains the
// other. Once these are disposed of, then the regions will intersect
// if and only if their boundaries intersect.
if r.IsEmpty() {
return false
}
if r.ContainsPoint(Point{c.id.rawPoint()}) {
return true
}
if c.ContainsPoint(PointFromLatLng(r.Center())) {
return true
}
// Quick rejection test (not required for correctness).
if !r.Intersects(c.RectBound()) {
return false
}
// Precompute the cell vertices as points and latitude-longitudes. We also
// check whether the Cell contains any corner of the rectangle, or
// vice-versa, since the edge-crossing tests only check the edge interiors.
vertices := [4]Point{}
latlngs := [4]LatLng{}
for i := range vertices {
vertices[i] = c.Vertex(i)
latlngs[i] = LatLngFromPoint(vertices[i])
if r.ContainsLatLng(latlngs[i]) {
return true
}
if c.ContainsPoint(PointFromLatLng(r.Vertex(i))) {
return true
}
}
// Now check whether the boundaries intersect. Unfortunately, a
// latitude-longitude rectangle does not have straight edges: two edges
// are curved, and at least one of them is concave.
for i := range vertices {
edgeLng := s1.IntervalFromEndpoints(latlngs[i].Lng.Radians(), latlngs[(i+1)&3].Lng.Radians())
if !r.Lng.Intersects(edgeLng) {
continue
}
a := vertices[i]
b := vertices[(i+1)&3]
if edgeLng.Contains(r.Lng.Lo) && intersectsLngEdge(a, b, r.Lat, s1.Angle(r.Lng.Lo)) {
return true
}
if edgeLng.Contains(r.Lng.Hi) && intersectsLngEdge(a, b, r.Lat, s1.Angle(r.Lng.Hi)) {
return true
}
if intersectsLatEdge(a, b, s1.Angle(r.Lat.Lo), r.Lng) {
return true
}
if intersectsLatEdge(a, b, s1.Angle(r.Lat.Hi), r.Lng) {
return true
}
}
return false
} | go | func (r Rect) IntersectsCell(c Cell) bool {
// First we eliminate the cases where one region completely contains the
// other. Once these are disposed of, then the regions will intersect
// if and only if their boundaries intersect.
if r.IsEmpty() {
return false
}
if r.ContainsPoint(Point{c.id.rawPoint()}) {
return true
}
if c.ContainsPoint(PointFromLatLng(r.Center())) {
return true
}
// Quick rejection test (not required for correctness).
if !r.Intersects(c.RectBound()) {
return false
}
// Precompute the cell vertices as points and latitude-longitudes. We also
// check whether the Cell contains any corner of the rectangle, or
// vice-versa, since the edge-crossing tests only check the edge interiors.
vertices := [4]Point{}
latlngs := [4]LatLng{}
for i := range vertices {
vertices[i] = c.Vertex(i)
latlngs[i] = LatLngFromPoint(vertices[i])
if r.ContainsLatLng(latlngs[i]) {
return true
}
if c.ContainsPoint(PointFromLatLng(r.Vertex(i))) {
return true
}
}
// Now check whether the boundaries intersect. Unfortunately, a
// latitude-longitude rectangle does not have straight edges: two edges
// are curved, and at least one of them is concave.
for i := range vertices {
edgeLng := s1.IntervalFromEndpoints(latlngs[i].Lng.Radians(), latlngs[(i+1)&3].Lng.Radians())
if !r.Lng.Intersects(edgeLng) {
continue
}
a := vertices[i]
b := vertices[(i+1)&3]
if edgeLng.Contains(r.Lng.Lo) && intersectsLngEdge(a, b, r.Lat, s1.Angle(r.Lng.Lo)) {
return true
}
if edgeLng.Contains(r.Lng.Hi) && intersectsLngEdge(a, b, r.Lat, s1.Angle(r.Lng.Hi)) {
return true
}
if intersectsLatEdge(a, b, s1.Angle(r.Lat.Lo), r.Lng) {
return true
}
if intersectsLatEdge(a, b, s1.Angle(r.Lat.Hi), r.Lng) {
return true
}
}
return false
} | [
"func",
"(",
"r",
"Rect",
")",
"IntersectsCell",
"(",
"c",
"Cell",
")",
"bool",
"{",
"// First we eliminate the cases where one region completely contains the",
"// other. Once these are disposed of, then the regions will intersect",
"// if and only if their boundaries intersect.",
"if",
"r",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"r",
".",
"ContainsPoint",
"(",
"Point",
"{",
"c",
".",
"id",
".",
"rawPoint",
"(",
")",
"}",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"if",
"c",
".",
"ContainsPoint",
"(",
"PointFromLatLng",
"(",
"r",
".",
"Center",
"(",
")",
")",
")",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"// Quick rejection test (not required for correctness).",
"if",
"!",
"r",
".",
"Intersects",
"(",
"c",
".",
"RectBound",
"(",
")",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"// Precompute the cell vertices as points and latitude-longitudes. We also",
"// check whether the Cell contains any corner of the rectangle, or",
"// vice-versa, since the edge-crossing tests only check the edge interiors.",
"vertices",
":=",
"[",
"4",
"]",
"Point",
"{",
"}",
"\n",
"latlngs",
":=",
"[",
"4",
"]",
"LatLng",
"{",
"}",
"\n\n",
"for",
"i",
":=",
"range",
"vertices",
"{",
"vertices",
"[",
"i",
"]",
"=",
"c",
".",
"Vertex",
"(",
"i",
")",
"\n",
"latlngs",
"[",
"i",
"]",
"=",
"LatLngFromPoint",
"(",
"vertices",
"[",
"i",
"]",
")",
"\n",
"if",
"r",
".",
"ContainsLatLng",
"(",
"latlngs",
"[",
"i",
"]",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"if",
"c",
".",
"ContainsPoint",
"(",
"PointFromLatLng",
"(",
"r",
".",
"Vertex",
"(",
"i",
")",
")",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Now check whether the boundaries intersect. Unfortunately, a",
"// latitude-longitude rectangle does not have straight edges: two edges",
"// are curved, and at least one of them is concave.",
"for",
"i",
":=",
"range",
"vertices",
"{",
"edgeLng",
":=",
"s1",
".",
"IntervalFromEndpoints",
"(",
"latlngs",
"[",
"i",
"]",
".",
"Lng",
".",
"Radians",
"(",
")",
",",
"latlngs",
"[",
"(",
"i",
"+",
"1",
")",
"&",
"3",
"]",
".",
"Lng",
".",
"Radians",
"(",
")",
")",
"\n",
"if",
"!",
"r",
".",
"Lng",
".",
"Intersects",
"(",
"edgeLng",
")",
"{",
"continue",
"\n",
"}",
"\n\n",
"a",
":=",
"vertices",
"[",
"i",
"]",
"\n",
"b",
":=",
"vertices",
"[",
"(",
"i",
"+",
"1",
")",
"&",
"3",
"]",
"\n",
"if",
"edgeLng",
".",
"Contains",
"(",
"r",
".",
"Lng",
".",
"Lo",
")",
"&&",
"intersectsLngEdge",
"(",
"a",
",",
"b",
",",
"r",
".",
"Lat",
",",
"s1",
".",
"Angle",
"(",
"r",
".",
"Lng",
".",
"Lo",
")",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"if",
"edgeLng",
".",
"Contains",
"(",
"r",
".",
"Lng",
".",
"Hi",
")",
"&&",
"intersectsLngEdge",
"(",
"a",
",",
"b",
",",
"r",
".",
"Lat",
",",
"s1",
".",
"Angle",
"(",
"r",
".",
"Lng",
".",
"Hi",
")",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"if",
"intersectsLatEdge",
"(",
"a",
",",
"b",
",",
"s1",
".",
"Angle",
"(",
"r",
".",
"Lat",
".",
"Lo",
")",
",",
"r",
".",
"Lng",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"if",
"intersectsLatEdge",
"(",
"a",
",",
"b",
",",
"s1",
".",
"Angle",
"(",
"r",
".",
"Lat",
".",
"Hi",
")",
",",
"r",
".",
"Lng",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // IntersectsCell reports whether this rectangle intersects the given cell. This is an
// exact test and may be fairly expensive. | [
"IntersectsCell",
"reports",
"whether",
"this",
"rectangle",
"intersects",
"the",
"given",
"cell",
".",
"This",
"is",
"an",
"exact",
"test",
"and",
"may",
"be",
"fairly",
"expensive",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L367-L428 |
150,012 | golang/geo | s2/rect.go | Encode | func (r Rect) Encode(w io.Writer) error {
e := &encoder{w: w}
r.encode(e)
return e.err
} | go | func (r Rect) Encode(w io.Writer) error {
e := &encoder{w: w}
r.encode(e)
return e.err
} | [
"func",
"(",
"r",
"Rect",
")",
"Encode",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"e",
":=",
"&",
"encoder",
"{",
"w",
":",
"w",
"}",
"\n",
"r",
".",
"encode",
"(",
"e",
")",
"\n",
"return",
"e",
".",
"err",
"\n",
"}"
] | // Encode encodes the Rect. | [
"Encode",
"encodes",
"the",
"Rect",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L431-L435 |
150,013 | golang/geo | s2/rect.go | Decode | func (r *Rect) Decode(rd io.Reader) error {
d := &decoder{r: asByteReader(rd)}
r.decode(d)
return d.err
} | go | func (r *Rect) Decode(rd io.Reader) error {
d := &decoder{r: asByteReader(rd)}
r.decode(d)
return d.err
} | [
"func",
"(",
"r",
"*",
"Rect",
")",
"Decode",
"(",
"rd",
"io",
".",
"Reader",
")",
"error",
"{",
"d",
":=",
"&",
"decoder",
"{",
"r",
":",
"asByteReader",
"(",
"rd",
")",
"}",
"\n",
"r",
".",
"decode",
"(",
"d",
")",
"\n",
"return",
"d",
".",
"err",
"\n",
"}"
] | // Decode decodes a rectangle. | [
"Decode",
"decodes",
"a",
"rectangle",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L446-L450 |
150,014 | golang/geo | s2/cap.go | CapFromCenterChordAngle | func CapFromCenterChordAngle(center Point, radius s1.ChordAngle) Cap {
return Cap{
center: center,
radius: radius,
}
} | go | func CapFromCenterChordAngle(center Point, radius s1.ChordAngle) Cap {
return Cap{
center: center,
radius: radius,
}
} | [
"func",
"CapFromCenterChordAngle",
"(",
"center",
"Point",
",",
"radius",
"s1",
".",
"ChordAngle",
")",
"Cap",
"{",
"return",
"Cap",
"{",
"center",
":",
"center",
",",
"radius",
":",
"radius",
",",
"}",
"\n",
"}"
] | // CapFromCenterChordAngle constructs a cap where the angle is expressed as an
// s1.ChordAngle. This constructor is more efficient than using an s1.Angle. | [
"CapFromCenterChordAngle",
"constructs",
"a",
"cap",
"where",
"the",
"angle",
"is",
"expressed",
"as",
"an",
"s1",
".",
"ChordAngle",
".",
"This",
"constructor",
"is",
"more",
"efficient",
"than",
"using",
"an",
"s1",
".",
"Angle",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L78-L83 |
150,015 | golang/geo | s2/cap.go | CapFromCenterHeight | func CapFromCenterHeight(center Point, height float64) Cap {
return CapFromCenterChordAngle(center, s1.ChordAngleFromSquaredLength(2*height))
} | go | func CapFromCenterHeight(center Point, height float64) Cap {
return CapFromCenterChordAngle(center, s1.ChordAngleFromSquaredLength(2*height))
} | [
"func",
"CapFromCenterHeight",
"(",
"center",
"Point",
",",
"height",
"float64",
")",
"Cap",
"{",
"return",
"CapFromCenterChordAngle",
"(",
"center",
",",
"s1",
".",
"ChordAngleFromSquaredLength",
"(",
"2",
"*",
"height",
")",
")",
"\n",
"}"
] | // CapFromCenterHeight constructs a cap with the given center and height. A
// negative height yields an empty cap; a height of 2 or more yields a full cap.
// The center should be unit length. | [
"CapFromCenterHeight",
"constructs",
"a",
"cap",
"with",
"the",
"given",
"center",
"and",
"height",
".",
"A",
"negative",
"height",
"yields",
"an",
"empty",
"cap",
";",
"a",
"height",
"of",
"2",
"or",
"more",
"yields",
"a",
"full",
"cap",
".",
"The",
"center",
"should",
"be",
"unit",
"length",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L88-L90 |
150,016 | golang/geo | s2/cap.go | IsValid | func (c Cap) IsValid() bool {
return c.center.Vector.IsUnit() && c.radius <= s1.StraightChordAngle
} | go | func (c Cap) IsValid() bool {
return c.center.Vector.IsUnit() && c.radius <= s1.StraightChordAngle
} | [
"func",
"(",
"c",
"Cap",
")",
"IsValid",
"(",
")",
"bool",
"{",
"return",
"c",
".",
"center",
".",
"Vector",
".",
"IsUnit",
"(",
")",
"&&",
"c",
".",
"radius",
"<=",
"s1",
".",
"StraightChordAngle",
"\n",
"}"
] | // IsValid reports whether the Cap is considered valid. | [
"IsValid",
"reports",
"whether",
"the",
"Cap",
"is",
"considered",
"valid",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L111-L113 |
150,017 | golang/geo | s2/cap.go | Equal | func (c Cap) Equal(other Cap) bool {
return (c.radius == other.radius && c.center == other.center) ||
(c.IsEmpty() && other.IsEmpty()) ||
(c.IsFull() && other.IsFull())
} | go | func (c Cap) Equal(other Cap) bool {
return (c.radius == other.radius && c.center == other.center) ||
(c.IsEmpty() && other.IsEmpty()) ||
(c.IsFull() && other.IsFull())
} | [
"func",
"(",
"c",
"Cap",
")",
"Equal",
"(",
"other",
"Cap",
")",
"bool",
"{",
"return",
"(",
"c",
".",
"radius",
"==",
"other",
".",
"radius",
"&&",
"c",
".",
"center",
"==",
"other",
".",
"center",
")",
"||",
"(",
"c",
".",
"IsEmpty",
"(",
")",
"&&",
"other",
".",
"IsEmpty",
"(",
")",
")",
"||",
"(",
"c",
".",
"IsFull",
"(",
")",
"&&",
"other",
".",
"IsFull",
"(",
")",
")",
"\n",
"}"
] | // Equal reports whether this cap is equal to the other cap. | [
"Equal",
"reports",
"whether",
"this",
"cap",
"is",
"equal",
"to",
"the",
"other",
"cap",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L259-L263 |
150,018 | golang/geo | s2/cap.go | ApproxEqual | func (c Cap) ApproxEqual(other Cap) bool {
const epsilon = 1e-14
r2 := float64(c.radius)
otherR2 := float64(other.radius)
return c.center.ApproxEqual(other.center) &&
math.Abs(r2-otherR2) <= epsilon ||
c.IsEmpty() && otherR2 <= epsilon ||
other.IsEmpty() && r2 <= epsilon ||
c.IsFull() && otherR2 >= 2-epsilon ||
other.IsFull() && r2 >= 2-epsilon
} | go | func (c Cap) ApproxEqual(other Cap) bool {
const epsilon = 1e-14
r2 := float64(c.radius)
otherR2 := float64(other.radius)
return c.center.ApproxEqual(other.center) &&
math.Abs(r2-otherR2) <= epsilon ||
c.IsEmpty() && otherR2 <= epsilon ||
other.IsEmpty() && r2 <= epsilon ||
c.IsFull() && otherR2 >= 2-epsilon ||
other.IsFull() && r2 >= 2-epsilon
} | [
"func",
"(",
"c",
"Cap",
")",
"ApproxEqual",
"(",
"other",
"Cap",
")",
"bool",
"{",
"const",
"epsilon",
"=",
"1e-14",
"\n",
"r2",
":=",
"float64",
"(",
"c",
".",
"radius",
")",
"\n",
"otherR2",
":=",
"float64",
"(",
"other",
".",
"radius",
")",
"\n",
"return",
"c",
".",
"center",
".",
"ApproxEqual",
"(",
"other",
".",
"center",
")",
"&&",
"math",
".",
"Abs",
"(",
"r2",
"-",
"otherR2",
")",
"<=",
"epsilon",
"||",
"c",
".",
"IsEmpty",
"(",
")",
"&&",
"otherR2",
"<=",
"epsilon",
"||",
"other",
".",
"IsEmpty",
"(",
")",
"&&",
"r2",
"<=",
"epsilon",
"||",
"c",
".",
"IsFull",
"(",
")",
"&&",
"otherR2",
">=",
"2",
"-",
"epsilon",
"||",
"other",
".",
"IsFull",
"(",
")",
"&&",
"r2",
">=",
"2",
"-",
"epsilon",
"\n",
"}"
] | // ApproxEqual reports whether this cap is equal to the other cap within the given tolerance. | [
"ApproxEqual",
"reports",
"whether",
"this",
"cap",
"is",
"equal",
"to",
"the",
"other",
"cap",
"within",
"the",
"given",
"tolerance",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L266-L276 |
150,019 | golang/geo | s2/cap.go | AddPoint | func (c Cap) AddPoint(p Point) Cap {
if c.IsEmpty() {
c.center = p
c.radius = 0
return c
}
// After calling cap.AddPoint(p), cap.Contains(p) must be true. However
// we don't need to do anything special to achieve this because Contains()
// does exactly the same distance calculation that we do here.
if newRad := ChordAngleBetweenPoints(c.center, p); newRad > c.radius {
c.radius = newRad
}
return c
} | go | func (c Cap) AddPoint(p Point) Cap {
if c.IsEmpty() {
c.center = p
c.radius = 0
return c
}
// After calling cap.AddPoint(p), cap.Contains(p) must be true. However
// we don't need to do anything special to achieve this because Contains()
// does exactly the same distance calculation that we do here.
if newRad := ChordAngleBetweenPoints(c.center, p); newRad > c.radius {
c.radius = newRad
}
return c
} | [
"func",
"(",
"c",
"Cap",
")",
"AddPoint",
"(",
"p",
"Point",
")",
"Cap",
"{",
"if",
"c",
".",
"IsEmpty",
"(",
")",
"{",
"c",
".",
"center",
"=",
"p",
"\n",
"c",
".",
"radius",
"=",
"0",
"\n",
"return",
"c",
"\n",
"}",
"\n\n",
"// After calling cap.AddPoint(p), cap.Contains(p) must be true. However",
"// we don't need to do anything special to achieve this because Contains()",
"// does exactly the same distance calculation that we do here.",
"if",
"newRad",
":=",
"ChordAngleBetweenPoints",
"(",
"c",
".",
"center",
",",
"p",
")",
";",
"newRad",
">",
"c",
".",
"radius",
"{",
"c",
".",
"radius",
"=",
"newRad",
"\n",
"}",
"\n",
"return",
"c",
"\n",
"}"
] | // AddPoint increases the cap if necessary to include the given point. If this cap is empty,
// then the center is set to the point with a zero height. p must be unit-length. | [
"AddPoint",
"increases",
"the",
"cap",
"if",
"necessary",
"to",
"include",
"the",
"given",
"point",
".",
"If",
"this",
"cap",
"is",
"empty",
"then",
"the",
"center",
"is",
"set",
"to",
"the",
"point",
"with",
"a",
"zero",
"height",
".",
"p",
"must",
"be",
"unit",
"-",
"length",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L280-L294 |
150,020 | golang/geo | s2/cap.go | AddCap | func (c Cap) AddCap(other Cap) Cap {
if c.IsEmpty() {
return other
}
if other.IsEmpty() {
return c
}
// We round up the distance to ensure that the cap is actually contained.
// TODO(roberts): Do some error analysis in order to guarantee this.
dist := ChordAngleBetweenPoints(c.center, other.center).Add(other.radius)
if newRad := dist.Expanded(dblEpsilon * float64(dist)); newRad > c.radius {
c.radius = newRad
}
return c
} | go | func (c Cap) AddCap(other Cap) Cap {
if c.IsEmpty() {
return other
}
if other.IsEmpty() {
return c
}
// We round up the distance to ensure that the cap is actually contained.
// TODO(roberts): Do some error analysis in order to guarantee this.
dist := ChordAngleBetweenPoints(c.center, other.center).Add(other.radius)
if newRad := dist.Expanded(dblEpsilon * float64(dist)); newRad > c.radius {
c.radius = newRad
}
return c
} | [
"func",
"(",
"c",
"Cap",
")",
"AddCap",
"(",
"other",
"Cap",
")",
"Cap",
"{",
"if",
"c",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"other",
"\n",
"}",
"\n",
"if",
"other",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"c",
"\n",
"}",
"\n\n",
"// We round up the distance to ensure that the cap is actually contained.",
"// TODO(roberts): Do some error analysis in order to guarantee this.",
"dist",
":=",
"ChordAngleBetweenPoints",
"(",
"c",
".",
"center",
",",
"other",
".",
"center",
")",
".",
"Add",
"(",
"other",
".",
"radius",
")",
"\n",
"if",
"newRad",
":=",
"dist",
".",
"Expanded",
"(",
"dblEpsilon",
"*",
"float64",
"(",
"dist",
")",
")",
";",
"newRad",
">",
"c",
".",
"radius",
"{",
"c",
".",
"radius",
"=",
"newRad",
"\n",
"}",
"\n",
"return",
"c",
"\n",
"}"
] | // AddCap increases the cap height if necessary to include the other cap. If this cap is empty,
// it is set to the other cap. | [
"AddCap",
"increases",
"the",
"cap",
"height",
"if",
"necessary",
"to",
"include",
"the",
"other",
"cap",
".",
"If",
"this",
"cap",
"is",
"empty",
"it",
"is",
"set",
"to",
"the",
"other",
"cap",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L298-L313 |
150,021 | golang/geo | s2/cap.go | ContainsCell | func (c Cap) ContainsCell(cell Cell) bool {
// If the cap does not contain all cell vertices, return false.
var vertices [4]Point
for k := 0; k < 4; k++ {
vertices[k] = cell.Vertex(k)
if !c.ContainsPoint(vertices[k]) {
return false
}
}
// Otherwise, return true if the complement of the cap does not intersect the cell.
return !c.Complement().intersects(cell, vertices)
} | go | func (c Cap) ContainsCell(cell Cell) bool {
// If the cap does not contain all cell vertices, return false.
var vertices [4]Point
for k := 0; k < 4; k++ {
vertices[k] = cell.Vertex(k)
if !c.ContainsPoint(vertices[k]) {
return false
}
}
// Otherwise, return true if the complement of the cap does not intersect the cell.
return !c.Complement().intersects(cell, vertices)
} | [
"func",
"(",
"c",
"Cap",
")",
"ContainsCell",
"(",
"cell",
"Cell",
")",
"bool",
"{",
"// If the cap does not contain all cell vertices, return false.",
"var",
"vertices",
"[",
"4",
"]",
"Point",
"\n",
"for",
"k",
":=",
"0",
";",
"k",
"<",
"4",
";",
"k",
"++",
"{",
"vertices",
"[",
"k",
"]",
"=",
"cell",
".",
"Vertex",
"(",
"k",
")",
"\n",
"if",
"!",
"c",
".",
"ContainsPoint",
"(",
"vertices",
"[",
"k",
"]",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"// Otherwise, return true if the complement of the cap does not intersect the cell.",
"return",
"!",
"c",
".",
"Complement",
"(",
")",
".",
"intersects",
"(",
"cell",
",",
"vertices",
")",
"\n",
"}"
] | // ContainsCell reports whether the cap contains the given cell. | [
"ContainsCell",
"reports",
"whether",
"the",
"cap",
"contains",
"the",
"given",
"cell",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L341-L352 |
150,022 | golang/geo | s2/cap.go | IntersectsCell | func (c Cap) IntersectsCell(cell Cell) bool {
// If the cap contains any cell vertex, return true.
var vertices [4]Point
for k := 0; k < 4; k++ {
vertices[k] = cell.Vertex(k)
if c.ContainsPoint(vertices[k]) {
return true
}
}
return c.intersects(cell, vertices)
} | go | func (c Cap) IntersectsCell(cell Cell) bool {
// If the cap contains any cell vertex, return true.
var vertices [4]Point
for k := 0; k < 4; k++ {
vertices[k] = cell.Vertex(k)
if c.ContainsPoint(vertices[k]) {
return true
}
}
return c.intersects(cell, vertices)
} | [
"func",
"(",
"c",
"Cap",
")",
"IntersectsCell",
"(",
"cell",
"Cell",
")",
"bool",
"{",
"// If the cap contains any cell vertex, return true.",
"var",
"vertices",
"[",
"4",
"]",
"Point",
"\n",
"for",
"k",
":=",
"0",
";",
"k",
"<",
"4",
";",
"k",
"++",
"{",
"vertices",
"[",
"k",
"]",
"=",
"cell",
".",
"Vertex",
"(",
"k",
")",
"\n",
"if",
"c",
".",
"ContainsPoint",
"(",
"vertices",
"[",
"k",
"]",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"c",
".",
"intersects",
"(",
"cell",
",",
"vertices",
")",
"\n",
"}"
] | // IntersectsCell reports whether the cap intersects the cell. | [
"IntersectsCell",
"reports",
"whether",
"the",
"cap",
"intersects",
"the",
"cell",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L355-L365 |
150,023 | golang/geo | s2/cap.go | CellUnionBound | func (c Cap) CellUnionBound() []CellID {
// TODO(roberts): The covering could be made quite a bit tighter by mapping
// the cap to a rectangle in (i,j)-space and finding a covering for that.
// Find the maximum level such that the cap contains at most one cell vertex
// and such that CellID.AppendVertexNeighbors() can be called.
level := MinWidthMetric.MaxLevel(c.Radius().Radians()) - 1
// If level < 0, more than three face cells are required.
if level < 0 {
cellIDs := make([]CellID, 6)
for face := 0; face < 6; face++ {
cellIDs[face] = CellIDFromFace(face)
}
return cellIDs
}
// The covering consists of the 4 cells at the given level that share the
// cell vertex that is closest to the cap center.
return cellIDFromPoint(c.center).VertexNeighbors(level)
} | go | func (c Cap) CellUnionBound() []CellID {
// TODO(roberts): The covering could be made quite a bit tighter by mapping
// the cap to a rectangle in (i,j)-space and finding a covering for that.
// Find the maximum level such that the cap contains at most one cell vertex
// and such that CellID.AppendVertexNeighbors() can be called.
level := MinWidthMetric.MaxLevel(c.Radius().Radians()) - 1
// If level < 0, more than three face cells are required.
if level < 0 {
cellIDs := make([]CellID, 6)
for face := 0; face < 6; face++ {
cellIDs[face] = CellIDFromFace(face)
}
return cellIDs
}
// The covering consists of the 4 cells at the given level that share the
// cell vertex that is closest to the cap center.
return cellIDFromPoint(c.center).VertexNeighbors(level)
} | [
"func",
"(",
"c",
"Cap",
")",
"CellUnionBound",
"(",
")",
"[",
"]",
"CellID",
"{",
"// TODO(roberts): The covering could be made quite a bit tighter by mapping",
"// the cap to a rectangle in (i,j)-space and finding a covering for that.",
"// Find the maximum level such that the cap contains at most one cell vertex",
"// and such that CellID.AppendVertexNeighbors() can be called.",
"level",
":=",
"MinWidthMetric",
".",
"MaxLevel",
"(",
"c",
".",
"Radius",
"(",
")",
".",
"Radians",
"(",
")",
")",
"-",
"1",
"\n\n",
"// If level < 0, more than three face cells are required.",
"if",
"level",
"<",
"0",
"{",
"cellIDs",
":=",
"make",
"(",
"[",
"]",
"CellID",
",",
"6",
")",
"\n",
"for",
"face",
":=",
"0",
";",
"face",
"<",
"6",
";",
"face",
"++",
"{",
"cellIDs",
"[",
"face",
"]",
"=",
"CellIDFromFace",
"(",
"face",
")",
"\n",
"}",
"\n",
"return",
"cellIDs",
"\n",
"}",
"\n",
"// The covering consists of the 4 cells at the given level that share the",
"// cell vertex that is closest to the cap center.",
"return",
"cellIDFromPoint",
"(",
"c",
".",
"center",
")",
".",
"VertexNeighbors",
"(",
"level",
")",
"\n",
"}"
] | // CellUnionBound computes a covering of the Cap. In general the covering
// consists of at most 4 cells except for very large caps, which may need
// up to 6 cells. The output is not sorted. | [
"CellUnionBound",
"computes",
"a",
"covering",
"of",
"the",
"Cap",
".",
"In",
"general",
"the",
"covering",
"consists",
"of",
"at",
"most",
"4",
"cells",
"except",
"for",
"very",
"large",
"caps",
"which",
"may",
"need",
"up",
"to",
"6",
"cells",
".",
"The",
"output",
"is",
"not",
"sorted",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L421-L440 |
150,024 | golang/geo | s2/cap.go | Union | func (c Cap) Union(other Cap) Cap {
// If the other cap is larger, swap c and other for the rest of the computations.
if c.radius < other.radius {
c, other = other, c
}
if c.IsFull() || other.IsEmpty() {
return c
}
// TODO: This calculation would be more efficient using s1.ChordAngles.
cRadius := c.Radius()
otherRadius := other.Radius()
distance := c.center.Distance(other.center)
if cRadius >= distance+otherRadius {
return c
}
resRadius := 0.5 * (distance + cRadius + otherRadius)
resCenter := InterpolateAtDistance(0.5*(distance-cRadius+otherRadius), c.center, other.center)
return CapFromCenterAngle(resCenter, resRadius)
} | go | func (c Cap) Union(other Cap) Cap {
// If the other cap is larger, swap c and other for the rest of the computations.
if c.radius < other.radius {
c, other = other, c
}
if c.IsFull() || other.IsEmpty() {
return c
}
// TODO: This calculation would be more efficient using s1.ChordAngles.
cRadius := c.Radius()
otherRadius := other.Radius()
distance := c.center.Distance(other.center)
if cRadius >= distance+otherRadius {
return c
}
resRadius := 0.5 * (distance + cRadius + otherRadius)
resCenter := InterpolateAtDistance(0.5*(distance-cRadius+otherRadius), c.center, other.center)
return CapFromCenterAngle(resCenter, resRadius)
} | [
"func",
"(",
"c",
"Cap",
")",
"Union",
"(",
"other",
"Cap",
")",
"Cap",
"{",
"// If the other cap is larger, swap c and other for the rest of the computations.",
"if",
"c",
".",
"radius",
"<",
"other",
".",
"radius",
"{",
"c",
",",
"other",
"=",
"other",
",",
"c",
"\n",
"}",
"\n\n",
"if",
"c",
".",
"IsFull",
"(",
")",
"||",
"other",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"c",
"\n",
"}",
"\n\n",
"// TODO: This calculation would be more efficient using s1.ChordAngles.",
"cRadius",
":=",
"c",
".",
"Radius",
"(",
")",
"\n",
"otherRadius",
":=",
"other",
".",
"Radius",
"(",
")",
"\n",
"distance",
":=",
"c",
".",
"center",
".",
"Distance",
"(",
"other",
".",
"center",
")",
"\n",
"if",
"cRadius",
">=",
"distance",
"+",
"otherRadius",
"{",
"return",
"c",
"\n",
"}",
"\n\n",
"resRadius",
":=",
"0.5",
"*",
"(",
"distance",
"+",
"cRadius",
"+",
"otherRadius",
")",
"\n",
"resCenter",
":=",
"InterpolateAtDistance",
"(",
"0.5",
"*",
"(",
"distance",
"-",
"cRadius",
"+",
"otherRadius",
")",
",",
"c",
".",
"center",
",",
"other",
".",
"center",
")",
"\n",
"return",
"CapFromCenterAngle",
"(",
"resCenter",
",",
"resRadius",
")",
"\n",
"}"
] | // Union returns the smallest cap which encloses this cap and other. | [
"Union",
"returns",
"the",
"smallest",
"cap",
"which",
"encloses",
"this",
"cap",
"and",
"other",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L470-L491 |
150,025 | golang/geo | s2/cap.go | Encode | func (c Cap) Encode(w io.Writer) error {
e := &encoder{w: w}
c.encode(e)
return e.err
} | go | func (c Cap) Encode(w io.Writer) error {
e := &encoder{w: w}
c.encode(e)
return e.err
} | [
"func",
"(",
"c",
"Cap",
")",
"Encode",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"e",
":=",
"&",
"encoder",
"{",
"w",
":",
"w",
"}",
"\n",
"c",
".",
"encode",
"(",
"e",
")",
"\n",
"return",
"e",
".",
"err",
"\n",
"}"
] | // Encode encodes the Cap. | [
"Encode",
"encodes",
"the",
"Cap",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L494-L498 |
150,026 | golang/geo | s2/cap.go | Decode | func (c *Cap) Decode(r io.Reader) error {
d := &decoder{r: asByteReader(r)}
c.decode(d)
return d.err
} | go | func (c *Cap) Decode(r io.Reader) error {
d := &decoder{r: asByteReader(r)}
c.decode(d)
return d.err
} | [
"func",
"(",
"c",
"*",
"Cap",
")",
"Decode",
"(",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"d",
":=",
"&",
"decoder",
"{",
"r",
":",
"asByteReader",
"(",
"r",
")",
"}",
"\n",
"c",
".",
"decode",
"(",
"d",
")",
"\n",
"return",
"d",
".",
"err",
"\n",
"}"
] | // Decode decodes the Cap. | [
"Decode",
"decodes",
"the",
"Cap",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L508-L512 |
150,027 | golang/geo | r1/interval.go | Equal | func (i Interval) Equal(oi Interval) bool {
return i == oi || i.IsEmpty() && oi.IsEmpty()
} | go | func (i Interval) Equal(oi Interval) bool {
return i == oi || i.IsEmpty() && oi.IsEmpty()
} | [
"func",
"(",
"i",
"Interval",
")",
"Equal",
"(",
"oi",
"Interval",
")",
"bool",
"{",
"return",
"i",
"==",
"oi",
"||",
"i",
".",
"IsEmpty",
"(",
")",
"&&",
"oi",
".",
"IsEmpty",
"(",
")",
"\n",
"}"
] | // Equal returns true iff the interval contains the same points as oi. | [
"Equal",
"returns",
"true",
"iff",
"the",
"interval",
"contains",
"the",
"same",
"points",
"as",
"oi",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L39-L41 |
150,028 | golang/geo | r1/interval.go | InteriorContains | func (i Interval) InteriorContains(p float64) bool {
return i.Lo < p && p < i.Hi
} | go | func (i Interval) InteriorContains(p float64) bool {
return i.Lo < p && p < i.Hi
} | [
"func",
"(",
"i",
"Interval",
")",
"InteriorContains",
"(",
"p",
"float64",
")",
"bool",
"{",
"return",
"i",
".",
"Lo",
"<",
"p",
"&&",
"p",
"<",
"i",
".",
"Hi",
"\n",
"}"
] | // InteriorContains returns true iff the interval strictly contains p. | [
"InteriorContains",
"returns",
"true",
"iff",
"the",
"interval",
"strictly",
"contains",
"p",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L63-L65 |
150,029 | golang/geo | r1/interval.go | Intersection | func (i Interval) Intersection(j Interval) Interval {
// Empty intervals do not need to be special-cased.
return Interval{
Lo: math.Max(i.Lo, j.Lo),
Hi: math.Min(i.Hi, j.Hi),
}
} | go | func (i Interval) Intersection(j Interval) Interval {
// Empty intervals do not need to be special-cased.
return Interval{
Lo: math.Max(i.Lo, j.Lo),
Hi: math.Min(i.Hi, j.Hi),
}
} | [
"func",
"(",
"i",
"Interval",
")",
"Intersection",
"(",
"j",
"Interval",
")",
"Interval",
"{",
"// Empty intervals do not need to be special-cased.",
"return",
"Interval",
"{",
"Lo",
":",
"math",
".",
"Max",
"(",
"i",
".",
"Lo",
",",
"j",
".",
"Lo",
")",
",",
"Hi",
":",
"math",
".",
"Min",
"(",
"i",
".",
"Hi",
",",
"j",
".",
"Hi",
")",
",",
"}",
"\n",
"}"
] | // Intersection returns the interval containing all points common to i and j. | [
"Intersection",
"returns",
"the",
"interval",
"containing",
"all",
"points",
"common",
"to",
"i",
"and",
"j",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L89-L95 |
150,030 | golang/geo | r1/interval.go | AddPoint | func (i Interval) AddPoint(p float64) Interval {
if i.IsEmpty() {
return Interval{p, p}
}
if p < i.Lo {
return Interval{p, i.Hi}
}
if p > i.Hi {
return Interval{i.Lo, p}
}
return i
} | go | func (i Interval) AddPoint(p float64) Interval {
if i.IsEmpty() {
return Interval{p, p}
}
if p < i.Lo {
return Interval{p, i.Hi}
}
if p > i.Hi {
return Interval{i.Lo, p}
}
return i
} | [
"func",
"(",
"i",
"Interval",
")",
"AddPoint",
"(",
"p",
"float64",
")",
"Interval",
"{",
"if",
"i",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"Interval",
"{",
"p",
",",
"p",
"}",
"\n",
"}",
"\n",
"if",
"p",
"<",
"i",
".",
"Lo",
"{",
"return",
"Interval",
"{",
"p",
",",
"i",
".",
"Hi",
"}",
"\n",
"}",
"\n",
"if",
"p",
">",
"i",
".",
"Hi",
"{",
"return",
"Interval",
"{",
"i",
".",
"Lo",
",",
"p",
"}",
"\n",
"}",
"\n",
"return",
"i",
"\n",
"}"
] | // AddPoint returns the interval expanded so that it contains the given point. | [
"AddPoint",
"returns",
"the",
"interval",
"expanded",
"so",
"that",
"it",
"contains",
"the",
"given",
"point",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L98-L109 |
150,031 | golang/geo | r1/interval.go | ClampPoint | func (i Interval) ClampPoint(p float64) float64 {
return math.Max(i.Lo, math.Min(i.Hi, p))
} | go | func (i Interval) ClampPoint(p float64) float64 {
return math.Max(i.Lo, math.Min(i.Hi, p))
} | [
"func",
"(",
"i",
"Interval",
")",
"ClampPoint",
"(",
"p",
"float64",
")",
"float64",
"{",
"return",
"math",
".",
"Max",
"(",
"i",
".",
"Lo",
",",
"math",
".",
"Min",
"(",
"i",
".",
"Hi",
",",
"p",
")",
")",
"\n",
"}"
] | // ClampPoint returns the closest point in the interval to the given point "p".
// The interval must be non-empty. | [
"ClampPoint",
"returns",
"the",
"closest",
"point",
"in",
"the",
"interval",
"to",
"the",
"given",
"point",
"p",
".",
"The",
"interval",
"must",
"be",
"non",
"-",
"empty",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L113-L115 |
150,032 | golang/geo | r1/interval.go | Expanded | func (i Interval) Expanded(margin float64) Interval {
if i.IsEmpty() {
return i
}
return Interval{i.Lo - margin, i.Hi + margin}
} | go | func (i Interval) Expanded(margin float64) Interval {
if i.IsEmpty() {
return i
}
return Interval{i.Lo - margin, i.Hi + margin}
} | [
"func",
"(",
"i",
"Interval",
")",
"Expanded",
"(",
"margin",
"float64",
")",
"Interval",
"{",
"if",
"i",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"i",
"\n",
"}",
"\n",
"return",
"Interval",
"{",
"i",
".",
"Lo",
"-",
"margin",
",",
"i",
".",
"Hi",
"+",
"margin",
"}",
"\n",
"}"
] | // Expanded returns an interval that has been expanded on each side by margin.
// If margin is negative, then the function shrinks the interval on
// each side by margin instead. The resulting interval may be empty. Any
// expansion of an empty interval remains empty. | [
"Expanded",
"returns",
"an",
"interval",
"that",
"has",
"been",
"expanded",
"on",
"each",
"side",
"by",
"margin",
".",
"If",
"margin",
"is",
"negative",
"then",
"the",
"function",
"shrinks",
"the",
"interval",
"on",
"each",
"side",
"by",
"margin",
"instead",
".",
"The",
"resulting",
"interval",
"may",
"be",
"empty",
".",
"Any",
"expansion",
"of",
"an",
"empty",
"interval",
"remains",
"empty",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L121-L126 |
150,033 | golang/geo | r1/interval.go | Union | func (i Interval) Union(other Interval) Interval {
if i.IsEmpty() {
return other
}
if other.IsEmpty() {
return i
}
return Interval{math.Min(i.Lo, other.Lo), math.Max(i.Hi, other.Hi)}
} | go | func (i Interval) Union(other Interval) Interval {
if i.IsEmpty() {
return other
}
if other.IsEmpty() {
return i
}
return Interval{math.Min(i.Lo, other.Lo), math.Max(i.Hi, other.Hi)}
} | [
"func",
"(",
"i",
"Interval",
")",
"Union",
"(",
"other",
"Interval",
")",
"Interval",
"{",
"if",
"i",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"other",
"\n",
"}",
"\n",
"if",
"other",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"i",
"\n",
"}",
"\n",
"return",
"Interval",
"{",
"math",
".",
"Min",
"(",
"i",
".",
"Lo",
",",
"other",
".",
"Lo",
")",
",",
"math",
".",
"Max",
"(",
"i",
".",
"Hi",
",",
"other",
".",
"Hi",
")",
"}",
"\n",
"}"
] | // Union returns the smallest interval that contains this interval and the given interval. | [
"Union",
"returns",
"the",
"smallest",
"interval",
"that",
"contains",
"this",
"interval",
"and",
"the",
"given",
"interval",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L129-L137 |
150,034 | golang/geo | r1/interval.go | ApproxEqual | func (i Interval) ApproxEqual(other Interval) bool {
if i.IsEmpty() {
return other.Length() <= 2*epsilon
}
if other.IsEmpty() {
return i.Length() <= 2*epsilon
}
return math.Abs(other.Lo-i.Lo) <= epsilon &&
math.Abs(other.Hi-i.Hi) <= epsilon
} | go | func (i Interval) ApproxEqual(other Interval) bool {
if i.IsEmpty() {
return other.Length() <= 2*epsilon
}
if other.IsEmpty() {
return i.Length() <= 2*epsilon
}
return math.Abs(other.Lo-i.Lo) <= epsilon &&
math.Abs(other.Hi-i.Hi) <= epsilon
} | [
"func",
"(",
"i",
"Interval",
")",
"ApproxEqual",
"(",
"other",
"Interval",
")",
"bool",
"{",
"if",
"i",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"other",
".",
"Length",
"(",
")",
"<=",
"2",
"*",
"epsilon",
"\n",
"}",
"\n",
"if",
"other",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"i",
".",
"Length",
"(",
")",
"<=",
"2",
"*",
"epsilon",
"\n",
"}",
"\n",
"return",
"math",
".",
"Abs",
"(",
"other",
".",
"Lo",
"-",
"i",
".",
"Lo",
")",
"<=",
"epsilon",
"&&",
"math",
".",
"Abs",
"(",
"other",
".",
"Hi",
"-",
"i",
".",
"Hi",
")",
"<=",
"epsilon",
"\n",
"}"
] | // ApproxEqual reports whether the interval can be transformed into the
// given interval by moving each endpoint a small distance.
// The empty interval is considered to be positioned arbitrarily on the
// real line, so any interval with a small enough length will match
// the empty interval. | [
"ApproxEqual",
"reports",
"whether",
"the",
"interval",
"can",
"be",
"transformed",
"into",
"the",
"given",
"interval",
"by",
"moving",
"each",
"endpoint",
"a",
"small",
"distance",
".",
"The",
"empty",
"interval",
"is",
"considered",
"to",
"be",
"positioned",
"arbitrarily",
"on",
"the",
"real",
"line",
"so",
"any",
"interval",
"with",
"a",
"small",
"enough",
"length",
"will",
"match",
"the",
"empty",
"interval",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L155-L164 |
150,035 | golang/geo | s2/convex_hull_query.go | AddPoint | func (q *ConvexHullQuery) AddPoint(p Point) {
q.bound = q.bound.AddPoint(LatLngFromPoint(p))
q.points = append(q.points, p)
} | go | func (q *ConvexHullQuery) AddPoint(p Point) {
q.bound = q.bound.AddPoint(LatLngFromPoint(p))
q.points = append(q.points, p)
} | [
"func",
"(",
"q",
"*",
"ConvexHullQuery",
")",
"AddPoint",
"(",
"p",
"Point",
")",
"{",
"q",
".",
"bound",
"=",
"q",
".",
"bound",
".",
"AddPoint",
"(",
"LatLngFromPoint",
"(",
"p",
")",
")",
"\n",
"q",
".",
"points",
"=",
"append",
"(",
"q",
".",
"points",
",",
"p",
")",
"\n",
"}"
] | // AddPoint adds the given point to the input geometry. | [
"AddPoint",
"adds",
"the",
"given",
"point",
"to",
"the",
"input",
"geometry",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/convex_hull_query.go#L71-L74 |
150,036 | golang/geo | s2/convex_hull_query.go | AddPolyline | func (q *ConvexHullQuery) AddPolyline(p *Polyline) {
q.bound = q.bound.Union(p.RectBound())
q.points = append(q.points, (*p)...)
} | go | func (q *ConvexHullQuery) AddPolyline(p *Polyline) {
q.bound = q.bound.Union(p.RectBound())
q.points = append(q.points, (*p)...)
} | [
"func",
"(",
"q",
"*",
"ConvexHullQuery",
")",
"AddPolyline",
"(",
"p",
"*",
"Polyline",
")",
"{",
"q",
".",
"bound",
"=",
"q",
".",
"bound",
".",
"Union",
"(",
"p",
".",
"RectBound",
"(",
")",
")",
"\n",
"q",
".",
"points",
"=",
"append",
"(",
"q",
".",
"points",
",",
"(",
"*",
"p",
")",
"...",
")",
"\n",
"}"
] | // AddPolyline adds the given polyline to the input geometry. | [
"AddPolyline",
"adds",
"the",
"given",
"polyline",
"to",
"the",
"input",
"geometry",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/convex_hull_query.go#L77-L80 |
150,037 | golang/geo | s2/convex_hull_query.go | AddLoop | func (q *ConvexHullQuery) AddLoop(l *Loop) {
q.bound = q.bound.Union(l.RectBound())
if l.isEmptyOrFull() {
return
}
q.points = append(q.points, l.vertices...)
} | go | func (q *ConvexHullQuery) AddLoop(l *Loop) {
q.bound = q.bound.Union(l.RectBound())
if l.isEmptyOrFull() {
return
}
q.points = append(q.points, l.vertices...)
} | [
"func",
"(",
"q",
"*",
"ConvexHullQuery",
")",
"AddLoop",
"(",
"l",
"*",
"Loop",
")",
"{",
"q",
".",
"bound",
"=",
"q",
".",
"bound",
".",
"Union",
"(",
"l",
".",
"RectBound",
"(",
")",
")",
"\n",
"if",
"l",
".",
"isEmptyOrFull",
"(",
")",
"{",
"return",
"\n",
"}",
"\n",
"q",
".",
"points",
"=",
"append",
"(",
"q",
".",
"points",
",",
"l",
".",
"vertices",
"...",
")",
"\n",
"}"
] | // AddLoop adds the given loop to the input geometry. | [
"AddLoop",
"adds",
"the",
"given",
"loop",
"to",
"the",
"input",
"geometry",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/convex_hull_query.go#L83-L89 |
150,038 | golang/geo | s2/convex_hull_query.go | AddPolygon | func (q *ConvexHullQuery) AddPolygon(p *Polygon) {
q.bound = q.bound.Union(p.RectBound())
for _, l := range p.loops {
// Only loops at depth 0 can contribute to the convex hull.
if l.depth == 0 {
q.AddLoop(l)
}
}
} | go | func (q *ConvexHullQuery) AddPolygon(p *Polygon) {
q.bound = q.bound.Union(p.RectBound())
for _, l := range p.loops {
// Only loops at depth 0 can contribute to the convex hull.
if l.depth == 0 {
q.AddLoop(l)
}
}
} | [
"func",
"(",
"q",
"*",
"ConvexHullQuery",
")",
"AddPolygon",
"(",
"p",
"*",
"Polygon",
")",
"{",
"q",
".",
"bound",
"=",
"q",
".",
"bound",
".",
"Union",
"(",
"p",
".",
"RectBound",
"(",
")",
")",
"\n",
"for",
"_",
",",
"l",
":=",
"range",
"p",
".",
"loops",
"{",
"// Only loops at depth 0 can contribute to the convex hull.",
"if",
"l",
".",
"depth",
"==",
"0",
"{",
"q",
".",
"AddLoop",
"(",
"l",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // AddPolygon adds the given polygon to the input geometry. | [
"AddPolygon",
"adds",
"the",
"given",
"polygon",
"to",
"the",
"input",
"geometry",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/convex_hull_query.go#L92-L100 |
150,039 | golang/geo | s2/convex_hull_query.go | singleEdgeLoop | func singleEdgeLoop(a, b Point) *Loop {
vertices := []Point{a, b, Point{a.Add(b.Vector).Normalize()}}
loop := LoopFromPoints(vertices)
// The resulting loop may be clockwise, so invert it if necessary.
loop.Normalize()
return loop
} | go | func singleEdgeLoop(a, b Point) *Loop {
vertices := []Point{a, b, Point{a.Add(b.Vector).Normalize()}}
loop := LoopFromPoints(vertices)
// The resulting loop may be clockwise, so invert it if necessary.
loop.Normalize()
return loop
} | [
"func",
"singleEdgeLoop",
"(",
"a",
",",
"b",
"Point",
")",
"*",
"Loop",
"{",
"vertices",
":=",
"[",
"]",
"Point",
"{",
"a",
",",
"b",
",",
"Point",
"{",
"a",
".",
"Add",
"(",
"b",
".",
"Vector",
")",
".",
"Normalize",
"(",
")",
"}",
"}",
"\n",
"loop",
":=",
"LoopFromPoints",
"(",
"vertices",
")",
"\n",
"// The resulting loop may be clockwise, so invert it if necessary.",
"loop",
".",
"Normalize",
"(",
")",
"\n",
"return",
"loop",
"\n",
"}"
] | // singleEdgeLoop constructs a loop consisting of the two vertices and their midpoint. | [
"singleEdgeLoop",
"constructs",
"a",
"loop",
"consisting",
"of",
"the",
"two",
"vertices",
"and",
"their",
"midpoint",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/convex_hull_query.go#L233-L239 |
150,040 | golang/geo | s1/chordangle.go | ChordAngleFromAngle | func ChordAngleFromAngle(a Angle) ChordAngle {
if a < 0 {
return NegativeChordAngle
}
if a.isInf() {
return InfChordAngle()
}
l := 2 * math.Sin(0.5*math.Min(math.Pi, a.Radians()))
return ChordAngle(l * l)
} | go | func ChordAngleFromAngle(a Angle) ChordAngle {
if a < 0 {
return NegativeChordAngle
}
if a.isInf() {
return InfChordAngle()
}
l := 2 * math.Sin(0.5*math.Min(math.Pi, a.Radians()))
return ChordAngle(l * l)
} | [
"func",
"ChordAngleFromAngle",
"(",
"a",
"Angle",
")",
"ChordAngle",
"{",
"if",
"a",
"<",
"0",
"{",
"return",
"NegativeChordAngle",
"\n",
"}",
"\n",
"if",
"a",
".",
"isInf",
"(",
")",
"{",
"return",
"InfChordAngle",
"(",
")",
"\n",
"}",
"\n",
"l",
":=",
"2",
"*",
"math",
".",
"Sin",
"(",
"0.5",
"*",
"math",
".",
"Min",
"(",
"math",
".",
"Pi",
",",
"a",
".",
"Radians",
"(",
")",
")",
")",
"\n",
"return",
"ChordAngle",
"(",
"l",
"*",
"l",
")",
"\n",
"}"
] | // ChordAngleFromAngle returns a ChordAngle from the given Angle. | [
"ChordAngleFromAngle",
"returns",
"a",
"ChordAngle",
"from",
"the",
"given",
"Angle",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s1/chordangle.go#L57-L66 |
150,041 | golang/geo | s1/chordangle.go | Angle | func (c ChordAngle) Angle() Angle {
if c < 0 {
return -1 * Radian
}
if c.isInf() {
return InfAngle()
}
return Angle(2 * math.Asin(0.5*math.Sqrt(float64(c))))
} | go | func (c ChordAngle) Angle() Angle {
if c < 0 {
return -1 * Radian
}
if c.isInf() {
return InfAngle()
}
return Angle(2 * math.Asin(0.5*math.Sqrt(float64(c))))
} | [
"func",
"(",
"c",
"ChordAngle",
")",
"Angle",
"(",
")",
"Angle",
"{",
"if",
"c",
"<",
"0",
"{",
"return",
"-",
"1",
"*",
"Radian",
"\n",
"}",
"\n",
"if",
"c",
".",
"isInf",
"(",
")",
"{",
"return",
"InfAngle",
"(",
")",
"\n",
"}",
"\n",
"return",
"Angle",
"(",
"2",
"*",
"math",
".",
"Asin",
"(",
"0.5",
"*",
"math",
".",
"Sqrt",
"(",
"float64",
"(",
"c",
")",
")",
")",
")",
"\n",
"}"
] | // Angle converts this ChordAngle to an Angle. | [
"Angle",
"converts",
"this",
"ChordAngle",
"to",
"an",
"Angle",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s1/chordangle.go#L92-L100 |
150,042 | golang/geo | s1/chordangle.go | Add | func (c ChordAngle) Add(other ChordAngle) ChordAngle {
// Note that this method (and Sub) is much more efficient than converting
// the ChordAngle to an Angle and adding those and converting back. It
// requires only one square root plus a few additions and multiplications.
// Optimization for the common case where b is an error tolerance
// parameter that happens to be set to zero.
if other == 0 {
return c
}
// Clamp the angle sum to at most 180 degrees.
if c+other >= maxLength2 {
return StraightChordAngle
}
// Let a and b be the (non-squared) chord lengths, and let c = a+b.
// Let A, B, and C be the corresponding half-angles (a = 2*sin(A), etc).
// Then the formula below can be derived from c = 2 * sin(A+B) and the
// relationships sin(A+B) = sin(A)*cos(B) + sin(B)*cos(A)
// cos(X) = sqrt(1 - sin^2(X))
x := float64(c * (1 - 0.25*other))
y := float64(other * (1 - 0.25*c))
return ChordAngle(math.Min(maxLength2, x+y+2*math.Sqrt(x*y)))
} | go | func (c ChordAngle) Add(other ChordAngle) ChordAngle {
// Note that this method (and Sub) is much more efficient than converting
// the ChordAngle to an Angle and adding those and converting back. It
// requires only one square root plus a few additions and multiplications.
// Optimization for the common case where b is an error tolerance
// parameter that happens to be set to zero.
if other == 0 {
return c
}
// Clamp the angle sum to at most 180 degrees.
if c+other >= maxLength2 {
return StraightChordAngle
}
// Let a and b be the (non-squared) chord lengths, and let c = a+b.
// Let A, B, and C be the corresponding half-angles (a = 2*sin(A), etc).
// Then the formula below can be derived from c = 2 * sin(A+B) and the
// relationships sin(A+B) = sin(A)*cos(B) + sin(B)*cos(A)
// cos(X) = sqrt(1 - sin^2(X))
x := float64(c * (1 - 0.25*other))
y := float64(other * (1 - 0.25*c))
return ChordAngle(math.Min(maxLength2, x+y+2*math.Sqrt(x*y)))
} | [
"func",
"(",
"c",
"ChordAngle",
")",
"Add",
"(",
"other",
"ChordAngle",
")",
"ChordAngle",
"{",
"// Note that this method (and Sub) is much more efficient than converting",
"// the ChordAngle to an Angle and adding those and converting back. It",
"// requires only one square root plus a few additions and multiplications.",
"// Optimization for the common case where b is an error tolerance",
"// parameter that happens to be set to zero.",
"if",
"other",
"==",
"0",
"{",
"return",
"c",
"\n",
"}",
"\n\n",
"// Clamp the angle sum to at most 180 degrees.",
"if",
"c",
"+",
"other",
">=",
"maxLength2",
"{",
"return",
"StraightChordAngle",
"\n",
"}",
"\n\n",
"// Let a and b be the (non-squared) chord lengths, and let c = a+b.",
"// Let A, B, and C be the corresponding half-angles (a = 2*sin(A), etc).",
"// Then the formula below can be derived from c = 2 * sin(A+B) and the",
"// relationships sin(A+B) = sin(A)*cos(B) + sin(B)*cos(A)",
"// cos(X) = sqrt(1 - sin^2(X))",
"x",
":=",
"float64",
"(",
"c",
"*",
"(",
"1",
"-",
"0.25",
"*",
"other",
")",
")",
"\n",
"y",
":=",
"float64",
"(",
"other",
"*",
"(",
"1",
"-",
"0.25",
"*",
"c",
")",
")",
"\n",
"return",
"ChordAngle",
"(",
"math",
".",
"Min",
"(",
"maxLength2",
",",
"x",
"+",
"y",
"+",
"2",
"*",
"math",
".",
"Sqrt",
"(",
"x",
"*",
"y",
")",
")",
")",
"\n",
"}"
] | // Add adds the other ChordAngle to this one and returns the resulting value.
// This method assumes the ChordAngles are not special. | [
"Add",
"adds",
"the",
"other",
"ChordAngle",
"to",
"this",
"one",
"and",
"returns",
"the",
"resulting",
"value",
".",
"This",
"method",
"assumes",
"the",
"ChordAngles",
"are",
"not",
"special",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s1/chordangle.go#L178-L202 |
150,043 | golang/geo | s1/chordangle.go | Sub | func (c ChordAngle) Sub(other ChordAngle) ChordAngle {
if other == 0 {
return c
}
if c <= other {
return 0
}
x := float64(c * (1 - 0.25*other))
y := float64(other * (1 - 0.25*c))
return ChordAngle(math.Max(0.0, x+y-2*math.Sqrt(x*y)))
} | go | func (c ChordAngle) Sub(other ChordAngle) ChordAngle {
if other == 0 {
return c
}
if c <= other {
return 0
}
x := float64(c * (1 - 0.25*other))
y := float64(other * (1 - 0.25*c))
return ChordAngle(math.Max(0.0, x+y-2*math.Sqrt(x*y)))
} | [
"func",
"(",
"c",
"ChordAngle",
")",
"Sub",
"(",
"other",
"ChordAngle",
")",
"ChordAngle",
"{",
"if",
"other",
"==",
"0",
"{",
"return",
"c",
"\n",
"}",
"\n",
"if",
"c",
"<=",
"other",
"{",
"return",
"0",
"\n",
"}",
"\n",
"x",
":=",
"float64",
"(",
"c",
"*",
"(",
"1",
"-",
"0.25",
"*",
"other",
")",
")",
"\n",
"y",
":=",
"float64",
"(",
"other",
"*",
"(",
"1",
"-",
"0.25",
"*",
"c",
")",
")",
"\n",
"return",
"ChordAngle",
"(",
"math",
".",
"Max",
"(",
"0.0",
",",
"x",
"+",
"y",
"-",
"2",
"*",
"math",
".",
"Sqrt",
"(",
"x",
"*",
"y",
")",
")",
")",
"\n",
"}"
] | // Sub subtracts the other ChordAngle from this one and returns the resulting
// value. This method assumes the ChordAngles are not special. | [
"Sub",
"subtracts",
"the",
"other",
"ChordAngle",
"from",
"this",
"one",
"and",
"returns",
"the",
"resulting",
"value",
".",
"This",
"method",
"assumes",
"the",
"ChordAngles",
"are",
"not",
"special",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s1/chordangle.go#L206-L216 |
150,044 | golang/geo | s2/edge_clipping.go | ClipEdge | func ClipEdge(a, b r2.Point, clip r2.Rect) (aClip, bClip r2.Point, intersects bool) {
// Compute the bounding rectangle of AB, clip it, and then extract the new
// endpoints from the clipped bound.
bound := r2.RectFromPoints(a, b)
if bound, intersects = clipEdgeBound(a, b, clip, bound); !intersects {
return aClip, bClip, false
}
ai := 0
if a.X > b.X {
ai = 1
}
aj := 0
if a.Y > b.Y {
aj = 1
}
return bound.VertexIJ(ai, aj), bound.VertexIJ(1-ai, 1-aj), true
} | go | func ClipEdge(a, b r2.Point, clip r2.Rect) (aClip, bClip r2.Point, intersects bool) {
// Compute the bounding rectangle of AB, clip it, and then extract the new
// endpoints from the clipped bound.
bound := r2.RectFromPoints(a, b)
if bound, intersects = clipEdgeBound(a, b, clip, bound); !intersects {
return aClip, bClip, false
}
ai := 0
if a.X > b.X {
ai = 1
}
aj := 0
if a.Y > b.Y {
aj = 1
}
return bound.VertexIJ(ai, aj), bound.VertexIJ(1-ai, 1-aj), true
} | [
"func",
"ClipEdge",
"(",
"a",
",",
"b",
"r2",
".",
"Point",
",",
"clip",
"r2",
".",
"Rect",
")",
"(",
"aClip",
",",
"bClip",
"r2",
".",
"Point",
",",
"intersects",
"bool",
")",
"{",
"// Compute the bounding rectangle of AB, clip it, and then extract the new",
"// endpoints from the clipped bound.",
"bound",
":=",
"r2",
".",
"RectFromPoints",
"(",
"a",
",",
"b",
")",
"\n",
"if",
"bound",
",",
"intersects",
"=",
"clipEdgeBound",
"(",
"a",
",",
"b",
",",
"clip",
",",
"bound",
")",
";",
"!",
"intersects",
"{",
"return",
"aClip",
",",
"bClip",
",",
"false",
"\n",
"}",
"\n",
"ai",
":=",
"0",
"\n",
"if",
"a",
".",
"X",
">",
"b",
".",
"X",
"{",
"ai",
"=",
"1",
"\n",
"}",
"\n",
"aj",
":=",
"0",
"\n",
"if",
"a",
".",
"Y",
">",
"b",
".",
"Y",
"{",
"aj",
"=",
"1",
"\n",
"}",
"\n\n",
"return",
"bound",
".",
"VertexIJ",
"(",
"ai",
",",
"aj",
")",
",",
"bound",
".",
"VertexIJ",
"(",
"1",
"-",
"ai",
",",
"1",
"-",
"aj",
")",
",",
"true",
"\n",
"}"
] | // ClipEdge returns the portion of the edge defined by AB that is contained by the
// given rectangle. If there is no intersection, false is returned and aClip and bClip
// are undefined. | [
"ClipEdge",
"returns",
"the",
"portion",
"of",
"the",
"edge",
"defined",
"by",
"AB",
"that",
"is",
"contained",
"by",
"the",
"given",
"rectangle",
".",
"If",
"there",
"is",
"no",
"intersection",
"false",
"is",
"returned",
"and",
"aClip",
"and",
"bClip",
"are",
"undefined",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_clipping.go#L140-L157 |
150,045 | golang/geo | s2/edge_clipping.go | updateEndpoint | func updateEndpoint(bound r1.Interval, highEndpoint bool, value float64) (r1.Interval, bool) {
if !highEndpoint {
if bound.Hi < value {
return bound, false
}
if bound.Lo < value {
bound.Lo = value
}
return bound, true
}
if bound.Lo > value {
return bound, false
}
if bound.Hi > value {
bound.Hi = value
}
return bound, true
} | go | func updateEndpoint(bound r1.Interval, highEndpoint bool, value float64) (r1.Interval, bool) {
if !highEndpoint {
if bound.Hi < value {
return bound, false
}
if bound.Lo < value {
bound.Lo = value
}
return bound, true
}
if bound.Lo > value {
return bound, false
}
if bound.Hi > value {
bound.Hi = value
}
return bound, true
} | [
"func",
"updateEndpoint",
"(",
"bound",
"r1",
".",
"Interval",
",",
"highEndpoint",
"bool",
",",
"value",
"float64",
")",
"(",
"r1",
".",
"Interval",
",",
"bool",
")",
"{",
"if",
"!",
"highEndpoint",
"{",
"if",
"bound",
".",
"Hi",
"<",
"value",
"{",
"return",
"bound",
",",
"false",
"\n",
"}",
"\n",
"if",
"bound",
".",
"Lo",
"<",
"value",
"{",
"bound",
".",
"Lo",
"=",
"value",
"\n",
"}",
"\n",
"return",
"bound",
",",
"true",
"\n",
"}",
"\n\n",
"if",
"bound",
".",
"Lo",
">",
"value",
"{",
"return",
"bound",
",",
"false",
"\n",
"}",
"\n",
"if",
"bound",
".",
"Hi",
">",
"value",
"{",
"bound",
".",
"Hi",
"=",
"value",
"\n",
"}",
"\n",
"return",
"bound",
",",
"true",
"\n",
"}"
] | // updateEndpoint returns the interval with the specified endpoint updated to
// the given value. If the value lies beyond the opposite endpoint, nothing is
// changed and false is returned. | [
"updateEndpoint",
"returns",
"the",
"interval",
"with",
"the",
"specified",
"endpoint",
"updated",
"to",
"the",
"given",
"value",
".",
"If",
"the",
"value",
"lies",
"beyond",
"the",
"opposite",
"endpoint",
"nothing",
"is",
"changed",
"and",
"false",
"is",
"returned",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_clipping.go#L364-L382 |
150,046 | golang/geo | s2/edge_clipping.go | edgeIntersectsRect | func edgeIntersectsRect(a, b r2.Point, r r2.Rect) bool {
// First check whether the bounds of a Rect around AB intersects the given rect.
if !r.Intersects(r2.RectFromPoints(a, b)) {
return false
}
// Otherwise AB intersects the rect if and only if all four vertices of rect
// do not lie on the same side of the extended line AB. We test this by finding
// the two vertices of rect with minimum and maximum projections onto the normal
// of AB, and computing their dot products with the edge normal.
n := b.Sub(a).Ortho()
i := 0
if n.X >= 0 {
i = 1
}
j := 0
if n.Y >= 0 {
j = 1
}
max := n.Dot(r.VertexIJ(i, j).Sub(a))
min := n.Dot(r.VertexIJ(1-i, 1-j).Sub(a))
return (max >= 0) && (min <= 0)
} | go | func edgeIntersectsRect(a, b r2.Point, r r2.Rect) bool {
// First check whether the bounds of a Rect around AB intersects the given rect.
if !r.Intersects(r2.RectFromPoints(a, b)) {
return false
}
// Otherwise AB intersects the rect if and only if all four vertices of rect
// do not lie on the same side of the extended line AB. We test this by finding
// the two vertices of rect with minimum and maximum projections onto the normal
// of AB, and computing their dot products with the edge normal.
n := b.Sub(a).Ortho()
i := 0
if n.X >= 0 {
i = 1
}
j := 0
if n.Y >= 0 {
j = 1
}
max := n.Dot(r.VertexIJ(i, j).Sub(a))
min := n.Dot(r.VertexIJ(1-i, 1-j).Sub(a))
return (max >= 0) && (min <= 0)
} | [
"func",
"edgeIntersectsRect",
"(",
"a",
",",
"b",
"r2",
".",
"Point",
",",
"r",
"r2",
".",
"Rect",
")",
"bool",
"{",
"// First check whether the bounds of a Rect around AB intersects the given rect.",
"if",
"!",
"r",
".",
"Intersects",
"(",
"r2",
".",
"RectFromPoints",
"(",
"a",
",",
"b",
")",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"// Otherwise AB intersects the rect if and only if all four vertices of rect",
"// do not lie on the same side of the extended line AB. We test this by finding",
"// the two vertices of rect with minimum and maximum projections onto the normal",
"// of AB, and computing their dot products with the edge normal.",
"n",
":=",
"b",
".",
"Sub",
"(",
"a",
")",
".",
"Ortho",
"(",
")",
"\n\n",
"i",
":=",
"0",
"\n",
"if",
"n",
".",
"X",
">=",
"0",
"{",
"i",
"=",
"1",
"\n",
"}",
"\n",
"j",
":=",
"0",
"\n",
"if",
"n",
".",
"Y",
">=",
"0",
"{",
"j",
"=",
"1",
"\n",
"}",
"\n\n",
"max",
":=",
"n",
".",
"Dot",
"(",
"r",
".",
"VertexIJ",
"(",
"i",
",",
"j",
")",
".",
"Sub",
"(",
"a",
")",
")",
"\n",
"min",
":=",
"n",
".",
"Dot",
"(",
"r",
".",
"VertexIJ",
"(",
"1",
"-",
"i",
",",
"1",
"-",
"j",
")",
".",
"Sub",
"(",
"a",
")",
")",
"\n\n",
"return",
"(",
"max",
">=",
"0",
")",
"&&",
"(",
"min",
"<=",
"0",
")",
"\n",
"}"
] | // edgeIntersectsRect reports whether the edge defined by AB intersects the
// given closed rectangle to within the error bound. | [
"edgeIntersectsRect",
"reports",
"whether",
"the",
"edge",
"defined",
"by",
"AB",
"intersects",
"the",
"given",
"closed",
"rectangle",
"to",
"within",
"the",
"error",
"bound",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_clipping.go#L421-L446 |
150,047 | golang/geo | s2/edge_clipping.go | clippedEdgeBound | func clippedEdgeBound(a, b r2.Point, clip r2.Rect) r2.Rect {
bound := r2.RectFromPoints(a, b)
if b1, intersects := clipEdgeBound(a, b, clip, bound); intersects {
return b1
}
return r2.EmptyRect()
} | go | func clippedEdgeBound(a, b r2.Point, clip r2.Rect) r2.Rect {
bound := r2.RectFromPoints(a, b)
if b1, intersects := clipEdgeBound(a, b, clip, bound); intersects {
return b1
}
return r2.EmptyRect()
} | [
"func",
"clippedEdgeBound",
"(",
"a",
",",
"b",
"r2",
".",
"Point",
",",
"clip",
"r2",
".",
"Rect",
")",
"r2",
".",
"Rect",
"{",
"bound",
":=",
"r2",
".",
"RectFromPoints",
"(",
"a",
",",
"b",
")",
"\n",
"if",
"b1",
",",
"intersects",
":=",
"clipEdgeBound",
"(",
"a",
",",
"b",
",",
"clip",
",",
"bound",
")",
";",
"intersects",
"{",
"return",
"b1",
"\n",
"}",
"\n",
"return",
"r2",
".",
"EmptyRect",
"(",
")",
"\n",
"}"
] | // clippedEdgeBound returns the bounding rectangle of the portion of the edge defined
// by AB intersected by clip. The resulting bound may be empty. This is a convenience
// function built on top of clipEdgeBound. | [
"clippedEdgeBound",
"returns",
"the",
"bounding",
"rectangle",
"of",
"the",
"portion",
"of",
"the",
"edge",
"defined",
"by",
"AB",
"intersected",
"by",
"clip",
".",
"The",
"resulting",
"bound",
"may",
"be",
"empty",
".",
"This",
"is",
"a",
"convenience",
"function",
"built",
"on",
"top",
"of",
"clipEdgeBound",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_clipping.go#L451-L457 |
150,048 | golang/geo | s2/edge_clipping.go | clipEdgeBound | func clipEdgeBound(a, b r2.Point, clip, bound r2.Rect) (r2.Rect, bool) {
// negSlope indicates which diagonal of the bounding box is spanned by AB: it
// is false if AB has positive slope, and true if AB has negative slope. This is
// used to determine which interval endpoints need to be updated each time
// the edge is clipped.
negSlope := (a.X > b.X) != (a.Y > b.Y)
b0x, b0y, up1 := clipBoundAxis(a.X, b.X, bound.X, a.Y, b.Y, bound.Y, negSlope, clip.X)
if !up1 {
return bound, false
}
b1y, b1x, up2 := clipBoundAxis(a.Y, b.Y, b0y, a.X, b.X, b0x, negSlope, clip.Y)
if !up2 {
return r2.Rect{b0x, b0y}, false
}
return r2.Rect{X: b1x, Y: b1y}, true
} | go | func clipEdgeBound(a, b r2.Point, clip, bound r2.Rect) (r2.Rect, bool) {
// negSlope indicates which diagonal of the bounding box is spanned by AB: it
// is false if AB has positive slope, and true if AB has negative slope. This is
// used to determine which interval endpoints need to be updated each time
// the edge is clipped.
negSlope := (a.X > b.X) != (a.Y > b.Y)
b0x, b0y, up1 := clipBoundAxis(a.X, b.X, bound.X, a.Y, b.Y, bound.Y, negSlope, clip.X)
if !up1 {
return bound, false
}
b1y, b1x, up2 := clipBoundAxis(a.Y, b.Y, b0y, a.X, b.X, b0x, negSlope, clip.Y)
if !up2 {
return r2.Rect{b0x, b0y}, false
}
return r2.Rect{X: b1x, Y: b1y}, true
} | [
"func",
"clipEdgeBound",
"(",
"a",
",",
"b",
"r2",
".",
"Point",
",",
"clip",
",",
"bound",
"r2",
".",
"Rect",
")",
"(",
"r2",
".",
"Rect",
",",
"bool",
")",
"{",
"// negSlope indicates which diagonal of the bounding box is spanned by AB: it",
"// is false if AB has positive slope, and true if AB has negative slope. This is",
"// used to determine which interval endpoints need to be updated each time",
"// the edge is clipped.",
"negSlope",
":=",
"(",
"a",
".",
"X",
">",
"b",
".",
"X",
")",
"!=",
"(",
"a",
".",
"Y",
">",
"b",
".",
"Y",
")",
"\n\n",
"b0x",
",",
"b0y",
",",
"up1",
":=",
"clipBoundAxis",
"(",
"a",
".",
"X",
",",
"b",
".",
"X",
",",
"bound",
".",
"X",
",",
"a",
".",
"Y",
",",
"b",
".",
"Y",
",",
"bound",
".",
"Y",
",",
"negSlope",
",",
"clip",
".",
"X",
")",
"\n",
"if",
"!",
"up1",
"{",
"return",
"bound",
",",
"false",
"\n",
"}",
"\n",
"b1y",
",",
"b1x",
",",
"up2",
":=",
"clipBoundAxis",
"(",
"a",
".",
"Y",
",",
"b",
".",
"Y",
",",
"b0y",
",",
"a",
".",
"X",
",",
"b",
".",
"X",
",",
"b0x",
",",
"negSlope",
",",
"clip",
".",
"Y",
")",
"\n",
"if",
"!",
"up2",
"{",
"return",
"r2",
".",
"Rect",
"{",
"b0x",
",",
"b0y",
"}",
",",
"false",
"\n",
"}",
"\n",
"return",
"r2",
".",
"Rect",
"{",
"X",
":",
"b1x",
",",
"Y",
":",
"b1y",
"}",
",",
"true",
"\n",
"}"
] | // clipEdgeBound clips an edge AB to sequence of rectangles efficiently.
// It represents the clipped edges by their bounding boxes rather than as a pair of
// endpoints. Specifically, let A'B' be some portion of an edge AB, and let bound be
// a tight bound of A'B'. This function returns the bound that is a tight bound
// of A'B' intersected with a given rectangle. If A'B' does not intersect clip,
// it returns false and the original bound. | [
"clipEdgeBound",
"clips",
"an",
"edge",
"AB",
"to",
"sequence",
"of",
"rectangles",
"efficiently",
".",
"It",
"represents",
"the",
"clipped",
"edges",
"by",
"their",
"bounding",
"boxes",
"rather",
"than",
"as",
"a",
"pair",
"of",
"endpoints",
".",
"Specifically",
"let",
"A",
"B",
"be",
"some",
"portion",
"of",
"an",
"edge",
"AB",
"and",
"let",
"bound",
"be",
"a",
"tight",
"bound",
"of",
"A",
"B",
".",
"This",
"function",
"returns",
"the",
"bound",
"that",
"is",
"a",
"tight",
"bound",
"of",
"A",
"B",
"intersected",
"with",
"a",
"given",
"rectangle",
".",
"If",
"A",
"B",
"does",
"not",
"intersect",
"clip",
"it",
"returns",
"false",
"and",
"the",
"original",
"bound",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_clipping.go#L465-L481 |
150,049 | golang/geo | s2/predicates.go | stableSign | func stableSign(a, b, c Point) Direction {
ab := b.Sub(a.Vector)
ab2 := ab.Norm2()
bc := c.Sub(b.Vector)
bc2 := bc.Norm2()
ca := a.Sub(c.Vector)
ca2 := ca.Norm2()
// Now compute the determinant ((A-C)x(B-C)).C, where the vertices have been
// cyclically permuted if necessary so that AB is the longest edge. (This
// minimizes the magnitude of cross product.) At the same time we also
// compute the maximum error in the determinant.
// The two shortest edges, pointing away from their common point.
var e1, e2, op r3.Vector
if ab2 >= bc2 && ab2 >= ca2 {
// AB is the longest edge.
e1, e2, op = ca, bc, c.Vector
} else if bc2 >= ca2 {
// BC is the longest edge.
e1, e2, op = ab, ca, a.Vector
} else {
// CA is the longest edge.
e1, e2, op = bc, ab, b.Vector
}
det := -e1.Cross(e2).Dot(op)
maxErr := detErrorMultiplier * math.Sqrt(e1.Norm2()*e2.Norm2())
// If the determinant isn't zero, within maxErr, we know definitively the point ordering.
if det > maxErr {
return CounterClockwise
}
if det < -maxErr {
return Clockwise
}
return Indeterminate
} | go | func stableSign(a, b, c Point) Direction {
ab := b.Sub(a.Vector)
ab2 := ab.Norm2()
bc := c.Sub(b.Vector)
bc2 := bc.Norm2()
ca := a.Sub(c.Vector)
ca2 := ca.Norm2()
// Now compute the determinant ((A-C)x(B-C)).C, where the vertices have been
// cyclically permuted if necessary so that AB is the longest edge. (This
// minimizes the magnitude of cross product.) At the same time we also
// compute the maximum error in the determinant.
// The two shortest edges, pointing away from their common point.
var e1, e2, op r3.Vector
if ab2 >= bc2 && ab2 >= ca2 {
// AB is the longest edge.
e1, e2, op = ca, bc, c.Vector
} else if bc2 >= ca2 {
// BC is the longest edge.
e1, e2, op = ab, ca, a.Vector
} else {
// CA is the longest edge.
e1, e2, op = bc, ab, b.Vector
}
det := -e1.Cross(e2).Dot(op)
maxErr := detErrorMultiplier * math.Sqrt(e1.Norm2()*e2.Norm2())
// If the determinant isn't zero, within maxErr, we know definitively the point ordering.
if det > maxErr {
return CounterClockwise
}
if det < -maxErr {
return Clockwise
}
return Indeterminate
} | [
"func",
"stableSign",
"(",
"a",
",",
"b",
",",
"c",
"Point",
")",
"Direction",
"{",
"ab",
":=",
"b",
".",
"Sub",
"(",
"a",
".",
"Vector",
")",
"\n",
"ab2",
":=",
"ab",
".",
"Norm2",
"(",
")",
"\n",
"bc",
":=",
"c",
".",
"Sub",
"(",
"b",
".",
"Vector",
")",
"\n",
"bc2",
":=",
"bc",
".",
"Norm2",
"(",
")",
"\n",
"ca",
":=",
"a",
".",
"Sub",
"(",
"c",
".",
"Vector",
")",
"\n",
"ca2",
":=",
"ca",
".",
"Norm2",
"(",
")",
"\n\n",
"// Now compute the determinant ((A-C)x(B-C)).C, where the vertices have been",
"// cyclically permuted if necessary so that AB is the longest edge. (This",
"// minimizes the magnitude of cross product.) At the same time we also",
"// compute the maximum error in the determinant.",
"// The two shortest edges, pointing away from their common point.",
"var",
"e1",
",",
"e2",
",",
"op",
"r3",
".",
"Vector",
"\n",
"if",
"ab2",
">=",
"bc2",
"&&",
"ab2",
">=",
"ca2",
"{",
"// AB is the longest edge.",
"e1",
",",
"e2",
",",
"op",
"=",
"ca",
",",
"bc",
",",
"c",
".",
"Vector",
"\n",
"}",
"else",
"if",
"bc2",
">=",
"ca2",
"{",
"// BC is the longest edge.",
"e1",
",",
"e2",
",",
"op",
"=",
"ab",
",",
"ca",
",",
"a",
".",
"Vector",
"\n",
"}",
"else",
"{",
"// CA is the longest edge.",
"e1",
",",
"e2",
",",
"op",
"=",
"bc",
",",
"ab",
",",
"b",
".",
"Vector",
"\n",
"}",
"\n\n",
"det",
":=",
"-",
"e1",
".",
"Cross",
"(",
"e2",
")",
".",
"Dot",
"(",
"op",
")",
"\n",
"maxErr",
":=",
"detErrorMultiplier",
"*",
"math",
".",
"Sqrt",
"(",
"e1",
".",
"Norm2",
"(",
")",
"*",
"e2",
".",
"Norm2",
"(",
")",
")",
"\n\n",
"// If the determinant isn't zero, within maxErr, we know definitively the point ordering.",
"if",
"det",
">",
"maxErr",
"{",
"return",
"CounterClockwise",
"\n",
"}",
"\n",
"if",
"det",
"<",
"-",
"maxErr",
"{",
"return",
"Clockwise",
"\n",
"}",
"\n",
"return",
"Indeterminate",
"\n",
"}"
] | // stableSign reports the direction sign of the points in a numerically stable way.
// Unlike triageSign, this method can usually compute the correct determinant sign
// even when all three points are as collinear as possible. For example if three
// points are spaced 1km apart along a random line on the Earth's surface using
// the nearest representable points, there is only a 0.4% chance that this method
// will not be able to find the determinant sign. The probability of failure
// decreases as the points get closer together; if the collinear points are 1 meter
// apart, the failure rate drops to 0.0004%.
//
// This method could be extended to also handle nearly-antipodal points, but antipodal
// points are rare in practice so it seems better to simply fall back to
// exact arithmetic in that case. | [
"stableSign",
"reports",
"the",
"direction",
"sign",
"of",
"the",
"points",
"in",
"a",
"numerically",
"stable",
"way",
".",
"Unlike",
"triageSign",
"this",
"method",
"can",
"usually",
"compute",
"the",
"correct",
"determinant",
"sign",
"even",
"when",
"all",
"three",
"points",
"are",
"as",
"collinear",
"as",
"possible",
".",
"For",
"example",
"if",
"three",
"points",
"are",
"spaced",
"1km",
"apart",
"along",
"a",
"random",
"line",
"on",
"the",
"Earth",
"s",
"surface",
"using",
"the",
"nearest",
"representable",
"points",
"there",
"is",
"only",
"a",
"0",
".",
"4%",
"chance",
"that",
"this",
"method",
"will",
"not",
"be",
"able",
"to",
"find",
"the",
"determinant",
"sign",
".",
"The",
"probability",
"of",
"failure",
"decreases",
"as",
"the",
"points",
"get",
"closer",
"together",
";",
"if",
"the",
"collinear",
"points",
"are",
"1",
"meter",
"apart",
"the",
"failure",
"rate",
"drops",
"to",
"0",
".",
"0004%",
".",
"This",
"method",
"could",
"be",
"extended",
"to",
"also",
"handle",
"nearly",
"-",
"antipodal",
"points",
"but",
"antipodal",
"points",
"are",
"rare",
"in",
"practice",
"so",
"it",
"seems",
"better",
"to",
"simply",
"fall",
"back",
"to",
"exact",
"arithmetic",
"in",
"that",
"case",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L156-L193 |
150,050 | golang/geo | s2/predicates.go | triageSign | func triageSign(a, b, c Point) Direction {
det := a.Cross(b.Vector).Dot(c.Vector)
if det > maxDeterminantError {
return CounterClockwise
}
if det < -maxDeterminantError {
return Clockwise
}
return Indeterminate
} | go | func triageSign(a, b, c Point) Direction {
det := a.Cross(b.Vector).Dot(c.Vector)
if det > maxDeterminantError {
return CounterClockwise
}
if det < -maxDeterminantError {
return Clockwise
}
return Indeterminate
} | [
"func",
"triageSign",
"(",
"a",
",",
"b",
",",
"c",
"Point",
")",
"Direction",
"{",
"det",
":=",
"a",
".",
"Cross",
"(",
"b",
".",
"Vector",
")",
".",
"Dot",
"(",
"c",
".",
"Vector",
")",
"\n",
"if",
"det",
">",
"maxDeterminantError",
"{",
"return",
"CounterClockwise",
"\n",
"}",
"\n",
"if",
"det",
"<",
"-",
"maxDeterminantError",
"{",
"return",
"Clockwise",
"\n",
"}",
"\n",
"return",
"Indeterminate",
"\n",
"}"
] | // triageSign returns the direction sign of the points. It returns Indeterminate if two
// points are identical or the result is uncertain. Uncertain cases can be resolved, if
// desired, by calling expensiveSign.
//
// The purpose of this method is to allow additional cheap tests to be done without
// calling expensiveSign. | [
"triageSign",
"returns",
"the",
"direction",
"sign",
"of",
"the",
"points",
".",
"It",
"returns",
"Indeterminate",
"if",
"two",
"points",
"are",
"identical",
"or",
"the",
"result",
"is",
"uncertain",
".",
"Uncertain",
"cases",
"can",
"be",
"resolved",
"if",
"desired",
"by",
"calling",
"expensiveSign",
".",
"The",
"purpose",
"of",
"this",
"method",
"is",
"to",
"allow",
"additional",
"cheap",
"tests",
"to",
"be",
"done",
"without",
"calling",
"expensiveSign",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L201-L210 |
150,051 | golang/geo | s2/predicates.go | expensiveSign | func expensiveSign(a, b, c Point) Direction {
// Return Indeterminate if and only if two points are the same.
// This ensures RobustSign(a,b,c) == Indeterminate if and only if a == b, b == c, or c == a.
// ie. Property 1 of RobustSign.
if a == b || b == c || c == a {
return Indeterminate
}
// Next we try recomputing the determinant still using floating-point
// arithmetic but in a more precise way. This is more expensive than the
// simple calculation done by triageSign, but it is still *much* cheaper
// than using arbitrary-precision arithmetic. This optimization is able to
// compute the correct determinant sign in virtually all cases except when
// the three points are truly collinear (e.g., three points on the equator).
detSign := stableSign(a, b, c)
if detSign != Indeterminate {
return Direction(detSign)
}
// Otherwise fall back to exact arithmetic and symbolic permutations.
return exactSign(a, b, c, true)
} | go | func expensiveSign(a, b, c Point) Direction {
// Return Indeterminate if and only if two points are the same.
// This ensures RobustSign(a,b,c) == Indeterminate if and only if a == b, b == c, or c == a.
// ie. Property 1 of RobustSign.
if a == b || b == c || c == a {
return Indeterminate
}
// Next we try recomputing the determinant still using floating-point
// arithmetic but in a more precise way. This is more expensive than the
// simple calculation done by triageSign, but it is still *much* cheaper
// than using arbitrary-precision arithmetic. This optimization is able to
// compute the correct determinant sign in virtually all cases except when
// the three points are truly collinear (e.g., three points on the equator).
detSign := stableSign(a, b, c)
if detSign != Indeterminate {
return Direction(detSign)
}
// Otherwise fall back to exact arithmetic and symbolic permutations.
return exactSign(a, b, c, true)
} | [
"func",
"expensiveSign",
"(",
"a",
",",
"b",
",",
"c",
"Point",
")",
"Direction",
"{",
"// Return Indeterminate if and only if two points are the same.",
"// This ensures RobustSign(a,b,c) == Indeterminate if and only if a == b, b == c, or c == a.",
"// ie. Property 1 of RobustSign.",
"if",
"a",
"==",
"b",
"||",
"b",
"==",
"c",
"||",
"c",
"==",
"a",
"{",
"return",
"Indeterminate",
"\n",
"}",
"\n\n",
"// Next we try recomputing the determinant still using floating-point",
"// arithmetic but in a more precise way. This is more expensive than the",
"// simple calculation done by triageSign, but it is still *much* cheaper",
"// than using arbitrary-precision arithmetic. This optimization is able to",
"// compute the correct determinant sign in virtually all cases except when",
"// the three points are truly collinear (e.g., three points on the equator).",
"detSign",
":=",
"stableSign",
"(",
"a",
",",
"b",
",",
"c",
")",
"\n",
"if",
"detSign",
"!=",
"Indeterminate",
"{",
"return",
"Direction",
"(",
"detSign",
")",
"\n",
"}",
"\n\n",
"// Otherwise fall back to exact arithmetic and symbolic permutations.",
"return",
"exactSign",
"(",
"a",
",",
"b",
",",
"c",
",",
"true",
")",
"\n",
"}"
] | // expensiveSign reports the direction sign of the points. It returns Indeterminate
// if two of the input points are the same. It uses multiple-precision arithmetic
// to ensure that its results are always self-consistent. | [
"expensiveSign",
"reports",
"the",
"direction",
"sign",
"of",
"the",
"points",
".",
"It",
"returns",
"Indeterminate",
"if",
"two",
"of",
"the",
"input",
"points",
"are",
"the",
"same",
".",
"It",
"uses",
"multiple",
"-",
"precision",
"arithmetic",
"to",
"ensure",
"that",
"its",
"results",
"are",
"always",
"self",
"-",
"consistent",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L215-L236 |
150,052 | golang/geo | s2/predicates.go | exactCompareDistances | func exactCompareDistances(x, a, b r3.PreciseVector) int {
// This code produces the same result as though all points were reprojected
// to lie exactly on the surface of the unit sphere. It is based on testing
// whether x.Dot(a.Normalize()) < x.Dot(b.Normalize()), reformulated
// so that it can be evaluated using exact arithmetic.
cosAX := x.Dot(a)
cosBX := x.Dot(b)
// If the two values have different signs, we need to handle that case now
// before squaring them below.
aSign := cosAX.Sign()
bSign := cosBX.Sign()
if aSign != bSign {
// If cos(AX) > cos(BX), then AX < BX.
if aSign > bSign {
return -1
}
return 1
}
cosAX2 := newBigFloat().Mul(cosAX, cosAX)
cosBX2 := newBigFloat().Mul(cosBX, cosBX)
cmp := newBigFloat().Sub(cosBX2.Mul(cosBX2, a.Norm2()), cosAX2.Mul(cosAX2, b.Norm2()))
return aSign * cmp.Sign()
} | go | func exactCompareDistances(x, a, b r3.PreciseVector) int {
// This code produces the same result as though all points were reprojected
// to lie exactly on the surface of the unit sphere. It is based on testing
// whether x.Dot(a.Normalize()) < x.Dot(b.Normalize()), reformulated
// so that it can be evaluated using exact arithmetic.
cosAX := x.Dot(a)
cosBX := x.Dot(b)
// If the two values have different signs, we need to handle that case now
// before squaring them below.
aSign := cosAX.Sign()
bSign := cosBX.Sign()
if aSign != bSign {
// If cos(AX) > cos(BX), then AX < BX.
if aSign > bSign {
return -1
}
return 1
}
cosAX2 := newBigFloat().Mul(cosAX, cosAX)
cosBX2 := newBigFloat().Mul(cosBX, cosBX)
cmp := newBigFloat().Sub(cosBX2.Mul(cosBX2, a.Norm2()), cosAX2.Mul(cosAX2, b.Norm2()))
return aSign * cmp.Sign()
} | [
"func",
"exactCompareDistances",
"(",
"x",
",",
"a",
",",
"b",
"r3",
".",
"PreciseVector",
")",
"int",
"{",
"// This code produces the same result as though all points were reprojected",
"// to lie exactly on the surface of the unit sphere. It is based on testing",
"// whether x.Dot(a.Normalize()) < x.Dot(b.Normalize()), reformulated",
"// so that it can be evaluated using exact arithmetic.",
"cosAX",
":=",
"x",
".",
"Dot",
"(",
"a",
")",
"\n",
"cosBX",
":=",
"x",
".",
"Dot",
"(",
"b",
")",
"\n\n",
"// If the two values have different signs, we need to handle that case now",
"// before squaring them below.",
"aSign",
":=",
"cosAX",
".",
"Sign",
"(",
")",
"\n",
"bSign",
":=",
"cosBX",
".",
"Sign",
"(",
")",
"\n",
"if",
"aSign",
"!=",
"bSign",
"{",
"// If cos(AX) > cos(BX), then AX < BX.",
"if",
"aSign",
">",
"bSign",
"{",
"return",
"-",
"1",
"\n",
"}",
"\n",
"return",
"1",
"\n",
"}",
"\n",
"cosAX2",
":=",
"newBigFloat",
"(",
")",
".",
"Mul",
"(",
"cosAX",
",",
"cosAX",
")",
"\n",
"cosBX2",
":=",
"newBigFloat",
"(",
")",
".",
"Mul",
"(",
"cosBX",
",",
"cosBX",
")",
"\n",
"cmp",
":=",
"newBigFloat",
"(",
")",
".",
"Sub",
"(",
"cosBX2",
".",
"Mul",
"(",
"cosBX2",
",",
"a",
".",
"Norm2",
"(",
")",
")",
",",
"cosAX2",
".",
"Mul",
"(",
"cosAX2",
",",
"b",
".",
"Norm2",
"(",
")",
")",
")",
"\n",
"return",
"aSign",
"*",
"cmp",
".",
"Sign",
"(",
")",
"\n",
"}"
] | // exactCompareDistances returns -1, 0, or 1 after comparing using the values as
// PreciseVectors. | [
"exactCompareDistances",
"returns",
"-",
"1",
"0",
"or",
"1",
"after",
"comparing",
"using",
"the",
"values",
"as",
"PreciseVectors",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L527-L550 |
150,053 | golang/geo | s2/predicates.go | CompareDistance | func CompareDistance(x, y Point, r s1.ChordAngle) int {
// As with CompareDistances, we start by comparing dot products because
// the sin^2 method is only valid when the distance XY and the limit "r" are
// both less than 90 degrees.
sign := triageCompareCosDistance(x, y, float64(r))
if sign != 0 {
return sign
}
// Unlike with CompareDistances, it's not worth using the sin^2 method
// when the distance limit is near 180 degrees because the ChordAngle
// representation itself has has a rounding error of up to 2e-8 radians for
// distances near 180 degrees.
if r < ca45Degrees {
sign = triageCompareSin2Distance(x, y, float64(r))
if sign != 0 {
return sign
}
}
return exactCompareDistance(r3.PreciseVectorFromVector(x.Vector), r3.PreciseVectorFromVector(y.Vector), big.NewFloat(float64(r)).SetPrec(big.MaxPrec))
} | go | func CompareDistance(x, y Point, r s1.ChordAngle) int {
// As with CompareDistances, we start by comparing dot products because
// the sin^2 method is only valid when the distance XY and the limit "r" are
// both less than 90 degrees.
sign := triageCompareCosDistance(x, y, float64(r))
if sign != 0 {
return sign
}
// Unlike with CompareDistances, it's not worth using the sin^2 method
// when the distance limit is near 180 degrees because the ChordAngle
// representation itself has has a rounding error of up to 2e-8 radians for
// distances near 180 degrees.
if r < ca45Degrees {
sign = triageCompareSin2Distance(x, y, float64(r))
if sign != 0 {
return sign
}
}
return exactCompareDistance(r3.PreciseVectorFromVector(x.Vector), r3.PreciseVectorFromVector(y.Vector), big.NewFloat(float64(r)).SetPrec(big.MaxPrec))
} | [
"func",
"CompareDistance",
"(",
"x",
",",
"y",
"Point",
",",
"r",
"s1",
".",
"ChordAngle",
")",
"int",
"{",
"// As with CompareDistances, we start by comparing dot products because",
"// the sin^2 method is only valid when the distance XY and the limit \"r\" are",
"// both less than 90 degrees.",
"sign",
":=",
"triageCompareCosDistance",
"(",
"x",
",",
"y",
",",
"float64",
"(",
"r",
")",
")",
"\n",
"if",
"sign",
"!=",
"0",
"{",
"return",
"sign",
"\n",
"}",
"\n\n",
"// Unlike with CompareDistances, it's not worth using the sin^2 method",
"// when the distance limit is near 180 degrees because the ChordAngle",
"// representation itself has has a rounding error of up to 2e-8 radians for",
"// distances near 180 degrees.",
"if",
"r",
"<",
"ca45Degrees",
"{",
"sign",
"=",
"triageCompareSin2Distance",
"(",
"x",
",",
"y",
",",
"float64",
"(",
"r",
")",
")",
"\n",
"if",
"sign",
"!=",
"0",
"{",
"return",
"sign",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"exactCompareDistance",
"(",
"r3",
".",
"PreciseVectorFromVector",
"(",
"x",
".",
"Vector",
")",
",",
"r3",
".",
"PreciseVectorFromVector",
"(",
"y",
".",
"Vector",
")",
",",
"big",
".",
"NewFloat",
"(",
"float64",
"(",
"r",
")",
")",
".",
"SetPrec",
"(",
"big",
".",
"MaxPrec",
")",
")",
"\n",
"}"
] | // CompareDistance returns -1, 0, or +1 according to whether the distance XY is
// respectively less than, equal to, or greater than the provided chord angle. Distances are measured
// with respect to the positions of all points as though they are projected to lie
// exactly on the surface of the unit sphere. | [
"CompareDistance",
"returns",
"-",
"1",
"0",
"or",
"+",
"1",
"according",
"to",
"whether",
"the",
"distance",
"XY",
"is",
"respectively",
"less",
"than",
"equal",
"to",
"or",
"greater",
"than",
"the",
"provided",
"chord",
"angle",
".",
"Distances",
"are",
"measured",
"with",
"respect",
"to",
"the",
"positions",
"of",
"all",
"points",
"as",
"though",
"they",
"are",
"projected",
"to",
"lie",
"exactly",
"on",
"the",
"surface",
"of",
"the",
"unit",
"sphere",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L592-L612 |
150,054 | golang/geo | s2/predicates.go | triageCompareCosDistance | func triageCompareCosDistance(x, y Point, r2 float64) int {
cosXY, cosXYError := cosDistance(x, y)
cosR := 1.0 - 0.5*r2
cosRError := 2.0 * dblError * cosR
diff := cosXY - cosR
err := cosXYError + cosRError
if diff > err {
return -1
}
if diff < -err {
return 1
}
return 0
} | go | func triageCompareCosDistance(x, y Point, r2 float64) int {
cosXY, cosXYError := cosDistance(x, y)
cosR := 1.0 - 0.5*r2
cosRError := 2.0 * dblError * cosR
diff := cosXY - cosR
err := cosXYError + cosRError
if diff > err {
return -1
}
if diff < -err {
return 1
}
return 0
} | [
"func",
"triageCompareCosDistance",
"(",
"x",
",",
"y",
"Point",
",",
"r2",
"float64",
")",
"int",
"{",
"cosXY",
",",
"cosXYError",
":=",
"cosDistance",
"(",
"x",
",",
"y",
")",
"\n",
"cosR",
":=",
"1.0",
"-",
"0.5",
"*",
"r2",
"\n",
"cosRError",
":=",
"2.0",
"*",
"dblError",
"*",
"cosR",
"\n",
"diff",
":=",
"cosXY",
"-",
"cosR",
"\n",
"err",
":=",
"cosXYError",
"+",
"cosRError",
"\n",
"if",
"diff",
">",
"err",
"{",
"return",
"-",
"1",
"\n",
"}",
"\n",
"if",
"diff",
"<",
"-",
"err",
"{",
"return",
"1",
"\n",
"}",
"\n",
"return",
"0",
"\n",
"}"
] | // triageCompareCosDistance returns -1, 0, or +1 according to whether the distance XY is
// less than, equal to, or greater than r2 respectively using cos distance. | [
"triageCompareCosDistance",
"returns",
"-",
"1",
"0",
"or",
"+",
"1",
"according",
"to",
"whether",
"the",
"distance",
"XY",
"is",
"less",
"than",
"equal",
"to",
"or",
"greater",
"than",
"r2",
"respectively",
"using",
"cos",
"distance",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L616-L629 |
150,055 | golang/geo | s2/predicates.go | triageCompareSin2Distance | func triageCompareSin2Distance(x, y Point, r2 float64) int {
// Only valid for distance limits < 90 degrees.
sin2XY, sin2XYError := sin2Distance(x, y)
sin2R := r2 * (1.0 - 0.25*r2)
sin2RError := 3.0 * dblError * sin2R
diff := sin2XY - sin2R
err := sin2XYError + sin2RError
if diff > err {
return 1
}
if diff < -err {
return -1
}
return 0
} | go | func triageCompareSin2Distance(x, y Point, r2 float64) int {
// Only valid for distance limits < 90 degrees.
sin2XY, sin2XYError := sin2Distance(x, y)
sin2R := r2 * (1.0 - 0.25*r2)
sin2RError := 3.0 * dblError * sin2R
diff := sin2XY - sin2R
err := sin2XYError + sin2RError
if diff > err {
return 1
}
if diff < -err {
return -1
}
return 0
} | [
"func",
"triageCompareSin2Distance",
"(",
"x",
",",
"y",
"Point",
",",
"r2",
"float64",
")",
"int",
"{",
"// Only valid for distance limits < 90 degrees.",
"sin2XY",
",",
"sin2XYError",
":=",
"sin2Distance",
"(",
"x",
",",
"y",
")",
"\n",
"sin2R",
":=",
"r2",
"*",
"(",
"1.0",
"-",
"0.25",
"*",
"r2",
")",
"\n",
"sin2RError",
":=",
"3.0",
"*",
"dblError",
"*",
"sin2R",
"\n",
"diff",
":=",
"sin2XY",
"-",
"sin2R",
"\n",
"err",
":=",
"sin2XYError",
"+",
"sin2RError",
"\n",
"if",
"diff",
">",
"err",
"{",
"return",
"1",
"\n",
"}",
"\n",
"if",
"diff",
"<",
"-",
"err",
"{",
"return",
"-",
"1",
"\n",
"}",
"\n",
"return",
"0",
"\n",
"}"
] | // triageCompareSin2Distance returns -1, 0, or +1 according to whether the distance XY is
// less than, equal to, or greater than r2 respectively using sin^2 distance. | [
"triageCompareSin2Distance",
"returns",
"-",
"1",
"0",
"or",
"+",
"1",
"according",
"to",
"whether",
"the",
"distance",
"XY",
"is",
"less",
"than",
"equal",
"to",
"or",
"greater",
"than",
"r2",
"respectively",
"using",
"sin^2",
"distance",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L633-L647 |
150,056 | golang/geo | s2/predicates.go | exactCompareDistance | func exactCompareDistance(x, y r3.PreciseVector, r2 *big.Float) int {
// This code produces the same result as though all points were reprojected
// to lie exactly on the surface of the unit sphere. It is based on
// comparing the cosine of the angle XY (when both points are projected to
// lie exactly on the sphere) to the given threshold.
cosXY := x.Dot(y)
cosR := newBigFloat().Sub(bigOne, newBigFloat().Mul(bigHalf, r2))
// If the two values have different signs, we need to handle that case now
// before squaring them below.
xySign := cosXY.Sign()
rSign := cosR.Sign()
if xySign != rSign {
if xySign > rSign {
return -1
}
return 1 // If cos(XY) > cos(r), then XY < r.
}
cmp := newBigFloat().Sub(
newBigFloat().Mul(
newBigFloat().Mul(cosR, cosR), newBigFloat().Mul(x.Norm2(), y.Norm2())),
newBigFloat().Mul(cosXY, cosXY))
return xySign * cmp.Sign()
} | go | func exactCompareDistance(x, y r3.PreciseVector, r2 *big.Float) int {
// This code produces the same result as though all points were reprojected
// to lie exactly on the surface of the unit sphere. It is based on
// comparing the cosine of the angle XY (when both points are projected to
// lie exactly on the sphere) to the given threshold.
cosXY := x.Dot(y)
cosR := newBigFloat().Sub(bigOne, newBigFloat().Mul(bigHalf, r2))
// If the two values have different signs, we need to handle that case now
// before squaring them below.
xySign := cosXY.Sign()
rSign := cosR.Sign()
if xySign != rSign {
if xySign > rSign {
return -1
}
return 1 // If cos(XY) > cos(r), then XY < r.
}
cmp := newBigFloat().Sub(
newBigFloat().Mul(
newBigFloat().Mul(cosR, cosR), newBigFloat().Mul(x.Norm2(), y.Norm2())),
newBigFloat().Mul(cosXY, cosXY))
return xySign * cmp.Sign()
} | [
"func",
"exactCompareDistance",
"(",
"x",
",",
"y",
"r3",
".",
"PreciseVector",
",",
"r2",
"*",
"big",
".",
"Float",
")",
"int",
"{",
"// This code produces the same result as though all points were reprojected",
"// to lie exactly on the surface of the unit sphere. It is based on",
"// comparing the cosine of the angle XY (when both points are projected to",
"// lie exactly on the sphere) to the given threshold.",
"cosXY",
":=",
"x",
".",
"Dot",
"(",
"y",
")",
"\n",
"cosR",
":=",
"newBigFloat",
"(",
")",
".",
"Sub",
"(",
"bigOne",
",",
"newBigFloat",
"(",
")",
".",
"Mul",
"(",
"bigHalf",
",",
"r2",
")",
")",
"\n\n",
"// If the two values have different signs, we need to handle that case now",
"// before squaring them below.",
"xySign",
":=",
"cosXY",
".",
"Sign",
"(",
")",
"\n",
"rSign",
":=",
"cosR",
".",
"Sign",
"(",
")",
"\n",
"if",
"xySign",
"!=",
"rSign",
"{",
"if",
"xySign",
">",
"rSign",
"{",
"return",
"-",
"1",
"\n",
"}",
"\n",
"return",
"1",
"// If cos(XY) > cos(r), then XY < r.",
"\n",
"}",
"\n",
"cmp",
":=",
"newBigFloat",
"(",
")",
".",
"Sub",
"(",
"newBigFloat",
"(",
")",
".",
"Mul",
"(",
"newBigFloat",
"(",
")",
".",
"Mul",
"(",
"cosR",
",",
"cosR",
")",
",",
"newBigFloat",
"(",
")",
".",
"Mul",
"(",
"x",
".",
"Norm2",
"(",
")",
",",
"y",
".",
"Norm2",
"(",
")",
")",
")",
",",
"newBigFloat",
"(",
")",
".",
"Mul",
"(",
"cosXY",
",",
"cosXY",
")",
")",
"\n",
"return",
"xySign",
"*",
"cmp",
".",
"Sign",
"(",
")",
"\n",
"}"
] | // exactCompareDistance returns -1, 0, or +1 after comparing using PreciseVectors. | [
"exactCompareDistance",
"returns",
"-",
"1",
"0",
"or",
"+",
"1",
"after",
"comparing",
"using",
"PreciseVectors",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L655-L678 |
150,057 | golang/geo | s2/rect_bounder.go | RectBound | func (r *RectBounder) RectBound() Rect {
return r.bound.expanded(LatLng{s1.Angle(2 * dblEpsilon), 0}).PolarClosure()
} | go | func (r *RectBounder) RectBound() Rect {
return r.bound.expanded(LatLng{s1.Angle(2 * dblEpsilon), 0}).PolarClosure()
} | [
"func",
"(",
"r",
"*",
"RectBounder",
")",
"RectBound",
"(",
")",
"Rect",
"{",
"return",
"r",
".",
"bound",
".",
"expanded",
"(",
"LatLng",
"{",
"s1",
".",
"Angle",
"(",
"2",
"*",
"dblEpsilon",
")",
",",
"0",
"}",
")",
".",
"PolarClosure",
"(",
")",
"\n",
"}"
] | // RectBound returns the bounding rectangle of the edge chain that connects the
// vertices defined so far. This bound satisfies the guarantee made
// above, i.e. if the edge chain defines a Loop, then the bound contains
// the LatLng coordinates of all Points contained by the loop. | [
"RectBound",
"returns",
"the",
"bounding",
"rectangle",
"of",
"the",
"edge",
"chain",
"that",
"connects",
"the",
"vertices",
"defined",
"so",
"far",
".",
"This",
"bound",
"satisfies",
"the",
"guarantee",
"made",
"above",
"i",
".",
"e",
".",
"if",
"the",
"edge",
"chain",
"defines",
"a",
"Loop",
"then",
"the",
"bound",
"contains",
"the",
"LatLng",
"coordinates",
"of",
"all",
"Points",
"contained",
"by",
"the",
"loop",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect_bounder.go#L202-L204 |
150,058 | golang/geo | s2/edge_distances.go | UpdateMaxDistance | func UpdateMaxDistance(x, a, b Point, maxDist s1.ChordAngle) (s1.ChordAngle, bool) {
dist := maxChordAngle(ChordAngleBetweenPoints(x, a), ChordAngleBetweenPoints(x, b))
if dist > s1.RightChordAngle {
dist, _ = updateMinDistance(Point{x.Mul(-1)}, a, b, dist, true)
dist = s1.StraightChordAngle - dist
}
if maxDist < dist {
return dist, true
}
return maxDist, false
} | go | func UpdateMaxDistance(x, a, b Point, maxDist s1.ChordAngle) (s1.ChordAngle, bool) {
dist := maxChordAngle(ChordAngleBetweenPoints(x, a), ChordAngleBetweenPoints(x, b))
if dist > s1.RightChordAngle {
dist, _ = updateMinDistance(Point{x.Mul(-1)}, a, b, dist, true)
dist = s1.StraightChordAngle - dist
}
if maxDist < dist {
return dist, true
}
return maxDist, false
} | [
"func",
"UpdateMaxDistance",
"(",
"x",
",",
"a",
",",
"b",
"Point",
",",
"maxDist",
"s1",
".",
"ChordAngle",
")",
"(",
"s1",
".",
"ChordAngle",
",",
"bool",
")",
"{",
"dist",
":=",
"maxChordAngle",
"(",
"ChordAngleBetweenPoints",
"(",
"x",
",",
"a",
")",
",",
"ChordAngleBetweenPoints",
"(",
"x",
",",
"b",
")",
")",
"\n",
"if",
"dist",
">",
"s1",
".",
"RightChordAngle",
"{",
"dist",
",",
"_",
"=",
"updateMinDistance",
"(",
"Point",
"{",
"x",
".",
"Mul",
"(",
"-",
"1",
")",
"}",
",",
"a",
",",
"b",
",",
"dist",
",",
"true",
")",
"\n",
"dist",
"=",
"s1",
".",
"StraightChordAngle",
"-",
"dist",
"\n",
"}",
"\n",
"if",
"maxDist",
"<",
"dist",
"{",
"return",
"dist",
",",
"true",
"\n",
"}",
"\n\n",
"return",
"maxDist",
",",
"false",
"\n",
"}"
] | // UpdateMaxDistance checks if the distance from X to the edge AB is greater
// than maxDist, and if so, returns the updated value and true.
// Otherwise it returns false. The case A == B is handled correctly. | [
"UpdateMaxDistance",
"checks",
"if",
"the",
"distance",
"from",
"X",
"to",
"the",
"edge",
"AB",
"is",
"greater",
"than",
"maxDist",
"and",
"if",
"so",
"returns",
"the",
"updated",
"value",
"and",
"true",
".",
"Otherwise",
"it",
"returns",
"false",
".",
"The",
"case",
"A",
"==",
"B",
"is",
"handled",
"correctly",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_distances.go#L62-L73 |
150,059 | golang/geo | s2/edge_distances.go | Project | func Project(x, a, b Point) Point {
aXb := a.PointCross(b)
// Find the closest point to X along the great circle through AB.
p := x.Sub(aXb.Mul(x.Dot(aXb.Vector) / aXb.Vector.Norm2()))
// If this point is on the edge AB, then it's the closest point.
if Sign(aXb, a, Point{p}) && Sign(Point{p}, b, aXb) {
return Point{p.Normalize()}
}
// Otherwise, the closest point is either A or B.
if x.Sub(a.Vector).Norm2() <= x.Sub(b.Vector).Norm2() {
return a
}
return b
} | go | func Project(x, a, b Point) Point {
aXb := a.PointCross(b)
// Find the closest point to X along the great circle through AB.
p := x.Sub(aXb.Mul(x.Dot(aXb.Vector) / aXb.Vector.Norm2()))
// If this point is on the edge AB, then it's the closest point.
if Sign(aXb, a, Point{p}) && Sign(Point{p}, b, aXb) {
return Point{p.Normalize()}
}
// Otherwise, the closest point is either A or B.
if x.Sub(a.Vector).Norm2() <= x.Sub(b.Vector).Norm2() {
return a
}
return b
} | [
"func",
"Project",
"(",
"x",
",",
"a",
",",
"b",
"Point",
")",
"Point",
"{",
"aXb",
":=",
"a",
".",
"PointCross",
"(",
"b",
")",
"\n",
"// Find the closest point to X along the great circle through AB.",
"p",
":=",
"x",
".",
"Sub",
"(",
"aXb",
".",
"Mul",
"(",
"x",
".",
"Dot",
"(",
"aXb",
".",
"Vector",
")",
"/",
"aXb",
".",
"Vector",
".",
"Norm2",
"(",
")",
")",
")",
"\n\n",
"// If this point is on the edge AB, then it's the closest point.",
"if",
"Sign",
"(",
"aXb",
",",
"a",
",",
"Point",
"{",
"p",
"}",
")",
"&&",
"Sign",
"(",
"Point",
"{",
"p",
"}",
",",
"b",
",",
"aXb",
")",
"{",
"return",
"Point",
"{",
"p",
".",
"Normalize",
"(",
")",
"}",
"\n",
"}",
"\n\n",
"// Otherwise, the closest point is either A or B.",
"if",
"x",
".",
"Sub",
"(",
"a",
".",
"Vector",
")",
".",
"Norm2",
"(",
")",
"<=",
"x",
".",
"Sub",
"(",
"b",
".",
"Vector",
")",
".",
"Norm2",
"(",
")",
"{",
"return",
"a",
"\n",
"}",
"\n",
"return",
"b",
"\n",
"}"
] | // Project returns the point along the edge AB that is closest to the point X.
// The fractional distance of this point along the edge AB can be obtained
// using DistanceFraction.
//
// This requires that all points are unit length. | [
"Project",
"returns",
"the",
"point",
"along",
"the",
"edge",
"AB",
"that",
"is",
"closest",
"to",
"the",
"point",
"X",
".",
"The",
"fractional",
"distance",
"of",
"this",
"point",
"along",
"the",
"edge",
"AB",
"can",
"be",
"obtained",
"using",
"DistanceFraction",
".",
"This",
"requires",
"that",
"all",
"points",
"are",
"unit",
"length",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_distances.go#L96-L111 |
150,060 | golang/geo | s2/edge_distances.go | InterpolateAtDistance | func InterpolateAtDistance(ax s1.Angle, a, b Point) Point {
aRad := ax.Radians()
// Use PointCross to compute the tangent vector at A towards B. The
// result is always perpendicular to A, even if A=B or A=-B, but it is not
// necessarily unit length. (We effectively normalize it below.)
normal := a.PointCross(b)
tangent := normal.Vector.Cross(a.Vector)
// Now compute the appropriate linear combination of A and "tangent". With
// infinite precision the result would always be unit length, but we
// normalize it anyway to ensure that the error is within acceptable bounds.
// (Otherwise errors can build up when the result of one interpolation is
// fed into another interpolation.)
return Point{(a.Mul(math.Cos(aRad)).Add(tangent.Mul(math.Sin(aRad) / tangent.Norm()))).Normalize()}
} | go | func InterpolateAtDistance(ax s1.Angle, a, b Point) Point {
aRad := ax.Radians()
// Use PointCross to compute the tangent vector at A towards B. The
// result is always perpendicular to A, even if A=B or A=-B, but it is not
// necessarily unit length. (We effectively normalize it below.)
normal := a.PointCross(b)
tangent := normal.Vector.Cross(a.Vector)
// Now compute the appropriate linear combination of A and "tangent". With
// infinite precision the result would always be unit length, but we
// normalize it anyway to ensure that the error is within acceptable bounds.
// (Otherwise errors can build up when the result of one interpolation is
// fed into another interpolation.)
return Point{(a.Mul(math.Cos(aRad)).Add(tangent.Mul(math.Sin(aRad) / tangent.Norm()))).Normalize()}
} | [
"func",
"InterpolateAtDistance",
"(",
"ax",
"s1",
".",
"Angle",
",",
"a",
",",
"b",
"Point",
")",
"Point",
"{",
"aRad",
":=",
"ax",
".",
"Radians",
"(",
")",
"\n\n",
"// Use PointCross to compute the tangent vector at A towards B. The",
"// result is always perpendicular to A, even if A=B or A=-B, but it is not",
"// necessarily unit length. (We effectively normalize it below.)",
"normal",
":=",
"a",
".",
"PointCross",
"(",
"b",
")",
"\n",
"tangent",
":=",
"normal",
".",
"Vector",
".",
"Cross",
"(",
"a",
".",
"Vector",
")",
"\n\n",
"// Now compute the appropriate linear combination of A and \"tangent\". With",
"// infinite precision the result would always be unit length, but we",
"// normalize it anyway to ensure that the error is within acceptable bounds.",
"// (Otherwise errors can build up when the result of one interpolation is",
"// fed into another interpolation.)",
"return",
"Point",
"{",
"(",
"a",
".",
"Mul",
"(",
"math",
".",
"Cos",
"(",
"aRad",
")",
")",
".",
"Add",
"(",
"tangent",
".",
"Mul",
"(",
"math",
".",
"Sin",
"(",
"aRad",
")",
"/",
"tangent",
".",
"Norm",
"(",
")",
")",
")",
")",
".",
"Normalize",
"(",
")",
"}",
"\n",
"}"
] | // InterpolateAtDistance returns the point X along the line segment AB whose
// distance from A is the angle ax. | [
"InterpolateAtDistance",
"returns",
"the",
"point",
"X",
"along",
"the",
"line",
"segment",
"AB",
"whose",
"distance",
"from",
"A",
"is",
"the",
"angle",
"ax",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_distances.go#L142-L157 |
150,061 | golang/geo | s2/edge_distances.go | updateMinDistance | func updateMinDistance(x, a, b Point, minDist s1.ChordAngle, alwaysUpdate bool) (s1.ChordAngle, bool) {
if d, ok := interiorDist(x, a, b, minDist, alwaysUpdate); ok {
// Minimum distance is attained along the edge interior.
return d, true
}
// Otherwise the minimum distance is to one of the endpoints.
xa2, xb2 := (x.Sub(a.Vector)).Norm2(), x.Sub(b.Vector).Norm2()
dist := s1.ChordAngle(math.Min(xa2, xb2))
if !alwaysUpdate && dist >= minDist {
return minDist, false
}
return dist, true
} | go | func updateMinDistance(x, a, b Point, minDist s1.ChordAngle, alwaysUpdate bool) (s1.ChordAngle, bool) {
if d, ok := interiorDist(x, a, b, minDist, alwaysUpdate); ok {
// Minimum distance is attained along the edge interior.
return d, true
}
// Otherwise the minimum distance is to one of the endpoints.
xa2, xb2 := (x.Sub(a.Vector)).Norm2(), x.Sub(b.Vector).Norm2()
dist := s1.ChordAngle(math.Min(xa2, xb2))
if !alwaysUpdate && dist >= minDist {
return minDist, false
}
return dist, true
} | [
"func",
"updateMinDistance",
"(",
"x",
",",
"a",
",",
"b",
"Point",
",",
"minDist",
"s1",
".",
"ChordAngle",
",",
"alwaysUpdate",
"bool",
")",
"(",
"s1",
".",
"ChordAngle",
",",
"bool",
")",
"{",
"if",
"d",
",",
"ok",
":=",
"interiorDist",
"(",
"x",
",",
"a",
",",
"b",
",",
"minDist",
",",
"alwaysUpdate",
")",
";",
"ok",
"{",
"// Minimum distance is attained along the edge interior.",
"return",
"d",
",",
"true",
"\n",
"}",
"\n\n",
"// Otherwise the minimum distance is to one of the endpoints.",
"xa2",
",",
"xb2",
":=",
"(",
"x",
".",
"Sub",
"(",
"a",
".",
"Vector",
")",
")",
".",
"Norm2",
"(",
")",
",",
"x",
".",
"Sub",
"(",
"b",
".",
"Vector",
")",
".",
"Norm2",
"(",
")",
"\n",
"dist",
":=",
"s1",
".",
"ChordAngle",
"(",
"math",
".",
"Min",
"(",
"xa2",
",",
"xb2",
")",
")",
"\n",
"if",
"!",
"alwaysUpdate",
"&&",
"dist",
">=",
"minDist",
"{",
"return",
"minDist",
",",
"false",
"\n",
"}",
"\n",
"return",
"dist",
",",
"true",
"\n",
"}"
] | // updateMinDistance computes the distance from a point X to a line segment AB,
// and if either the distance was less than the given minDist, or alwaysUpdate is
// true, the value and whether it was updated are returned. | [
"updateMinDistance",
"computes",
"the",
"distance",
"from",
"a",
"point",
"X",
"to",
"a",
"line",
"segment",
"AB",
"and",
"if",
"either",
"the",
"distance",
"was",
"less",
"than",
"the",
"given",
"minDist",
"or",
"alwaysUpdate",
"is",
"true",
"the",
"value",
"and",
"whether",
"it",
"was",
"updated",
"are",
"returned",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_distances.go#L207-L220 |
150,062 | golang/geo | s2/edge_distances.go | updateEdgePairMinDistance | func updateEdgePairMinDistance(a0, a1, b0, b1 Point, minDist s1.ChordAngle) (s1.ChordAngle, bool) {
if minDist == 0 {
return 0, false
}
if CrossingSign(a0, a1, b0, b1) == Cross {
minDist = 0
return 0, true
}
// Otherwise, the minimum distance is achieved at an endpoint of at least
// one of the two edges. We ensure that all four possibilities are always checked.
//
// The calculation below computes each of the six vertex-vertex distances
// twice (this could be optimized).
var ok1, ok2, ok3, ok4 bool
minDist, ok1 = UpdateMinDistance(a0, b0, b1, minDist)
minDist, ok2 = UpdateMinDistance(a1, b0, b1, minDist)
minDist, ok3 = UpdateMinDistance(b0, a0, a1, minDist)
minDist, ok4 = UpdateMinDistance(b1, a0, a1, minDist)
return minDist, ok1 || ok2 || ok3 || ok4
} | go | func updateEdgePairMinDistance(a0, a1, b0, b1 Point, minDist s1.ChordAngle) (s1.ChordAngle, bool) {
if minDist == 0 {
return 0, false
}
if CrossingSign(a0, a1, b0, b1) == Cross {
minDist = 0
return 0, true
}
// Otherwise, the minimum distance is achieved at an endpoint of at least
// one of the two edges. We ensure that all four possibilities are always checked.
//
// The calculation below computes each of the six vertex-vertex distances
// twice (this could be optimized).
var ok1, ok2, ok3, ok4 bool
minDist, ok1 = UpdateMinDistance(a0, b0, b1, minDist)
minDist, ok2 = UpdateMinDistance(a1, b0, b1, minDist)
minDist, ok3 = UpdateMinDistance(b0, a0, a1, minDist)
minDist, ok4 = UpdateMinDistance(b1, a0, a1, minDist)
return minDist, ok1 || ok2 || ok3 || ok4
} | [
"func",
"updateEdgePairMinDistance",
"(",
"a0",
",",
"a1",
",",
"b0",
",",
"b1",
"Point",
",",
"minDist",
"s1",
".",
"ChordAngle",
")",
"(",
"s1",
".",
"ChordAngle",
",",
"bool",
")",
"{",
"if",
"minDist",
"==",
"0",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n",
"if",
"CrossingSign",
"(",
"a0",
",",
"a1",
",",
"b0",
",",
"b1",
")",
"==",
"Cross",
"{",
"minDist",
"=",
"0",
"\n",
"return",
"0",
",",
"true",
"\n",
"}",
"\n\n",
"// Otherwise, the minimum distance is achieved at an endpoint of at least",
"// one of the two edges. We ensure that all four possibilities are always checked.",
"//",
"// The calculation below computes each of the six vertex-vertex distances",
"// twice (this could be optimized).",
"var",
"ok1",
",",
"ok2",
",",
"ok3",
",",
"ok4",
"bool",
"\n",
"minDist",
",",
"ok1",
"=",
"UpdateMinDistance",
"(",
"a0",
",",
"b0",
",",
"b1",
",",
"minDist",
")",
"\n",
"minDist",
",",
"ok2",
"=",
"UpdateMinDistance",
"(",
"a1",
",",
"b0",
",",
"b1",
",",
"minDist",
")",
"\n",
"minDist",
",",
"ok3",
"=",
"UpdateMinDistance",
"(",
"b0",
",",
"a0",
",",
"a1",
",",
"minDist",
")",
"\n",
"minDist",
",",
"ok4",
"=",
"UpdateMinDistance",
"(",
"b1",
",",
"a0",
",",
"a1",
",",
"minDist",
")",
"\n",
"return",
"minDist",
",",
"ok1",
"||",
"ok2",
"||",
"ok3",
"||",
"ok4",
"\n",
"}"
] | // updateEdgePairMinDistance computes the minimum distance between the given
// pair of edges. If the two edges cross, the distance is zero. The cases
// a0 == a1 and b0 == b1 are handled correctly. | [
"updateEdgePairMinDistance",
"computes",
"the",
"minimum",
"distance",
"between",
"the",
"given",
"pair",
"of",
"edges",
".",
"If",
"the",
"two",
"edges",
"cross",
"the",
"distance",
"is",
"zero",
".",
"The",
"cases",
"a0",
"==",
"a1",
"and",
"b0",
"==",
"b1",
"are",
"handled",
"correctly",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_distances.go#L300-L320 |
150,063 | golang/geo | s2/edge_distances.go | updateEdgePairMaxDistance | func updateEdgePairMaxDistance(a0, a1, b0, b1 Point, maxDist s1.ChordAngle) (s1.ChordAngle, bool) {
if maxDist == s1.StraightChordAngle {
return s1.StraightChordAngle, false
}
if CrossingSign(a0, a1, Point{b0.Mul(-1)}, Point{b1.Mul(-1)}) == Cross {
return s1.StraightChordAngle, true
}
// Otherwise, the maximum distance is achieved at an endpoint of at least
// one of the two edges. We ensure that all four possibilities are always checked.
//
// The calculation below computes each of the six vertex-vertex distances
// twice (this could be optimized).
var ok1, ok2, ok3, ok4 bool
maxDist, ok1 = UpdateMaxDistance(a0, b0, b1, maxDist)
maxDist, ok2 = UpdateMaxDistance(a1, b0, b1, maxDist)
maxDist, ok3 = UpdateMaxDistance(b0, a0, a1, maxDist)
maxDist, ok4 = UpdateMaxDistance(b1, a0, a1, maxDist)
return maxDist, ok1 || ok2 || ok3 || ok4
} | go | func updateEdgePairMaxDistance(a0, a1, b0, b1 Point, maxDist s1.ChordAngle) (s1.ChordAngle, bool) {
if maxDist == s1.StraightChordAngle {
return s1.StraightChordAngle, false
}
if CrossingSign(a0, a1, Point{b0.Mul(-1)}, Point{b1.Mul(-1)}) == Cross {
return s1.StraightChordAngle, true
}
// Otherwise, the maximum distance is achieved at an endpoint of at least
// one of the two edges. We ensure that all four possibilities are always checked.
//
// The calculation below computes each of the six vertex-vertex distances
// twice (this could be optimized).
var ok1, ok2, ok3, ok4 bool
maxDist, ok1 = UpdateMaxDistance(a0, b0, b1, maxDist)
maxDist, ok2 = UpdateMaxDistance(a1, b0, b1, maxDist)
maxDist, ok3 = UpdateMaxDistance(b0, a0, a1, maxDist)
maxDist, ok4 = UpdateMaxDistance(b1, a0, a1, maxDist)
return maxDist, ok1 || ok2 || ok3 || ok4
} | [
"func",
"updateEdgePairMaxDistance",
"(",
"a0",
",",
"a1",
",",
"b0",
",",
"b1",
"Point",
",",
"maxDist",
"s1",
".",
"ChordAngle",
")",
"(",
"s1",
".",
"ChordAngle",
",",
"bool",
")",
"{",
"if",
"maxDist",
"==",
"s1",
".",
"StraightChordAngle",
"{",
"return",
"s1",
".",
"StraightChordAngle",
",",
"false",
"\n",
"}",
"\n",
"if",
"CrossingSign",
"(",
"a0",
",",
"a1",
",",
"Point",
"{",
"b0",
".",
"Mul",
"(",
"-",
"1",
")",
"}",
",",
"Point",
"{",
"b1",
".",
"Mul",
"(",
"-",
"1",
")",
"}",
")",
"==",
"Cross",
"{",
"return",
"s1",
".",
"StraightChordAngle",
",",
"true",
"\n",
"}",
"\n\n",
"// Otherwise, the maximum distance is achieved at an endpoint of at least",
"// one of the two edges. We ensure that all four possibilities are always checked.",
"//",
"// The calculation below computes each of the six vertex-vertex distances",
"// twice (this could be optimized).",
"var",
"ok1",
",",
"ok2",
",",
"ok3",
",",
"ok4",
"bool",
"\n",
"maxDist",
",",
"ok1",
"=",
"UpdateMaxDistance",
"(",
"a0",
",",
"b0",
",",
"b1",
",",
"maxDist",
")",
"\n",
"maxDist",
",",
"ok2",
"=",
"UpdateMaxDistance",
"(",
"a1",
",",
"b0",
",",
"b1",
",",
"maxDist",
")",
"\n",
"maxDist",
",",
"ok3",
"=",
"UpdateMaxDistance",
"(",
"b0",
",",
"a0",
",",
"a1",
",",
"maxDist",
")",
"\n",
"maxDist",
",",
"ok4",
"=",
"UpdateMaxDistance",
"(",
"b1",
",",
"a0",
",",
"a1",
",",
"maxDist",
")",
"\n",
"return",
"maxDist",
",",
"ok1",
"||",
"ok2",
"||",
"ok3",
"||",
"ok4",
"\n",
"}"
] | // updateEdgePairMaxDistance reports the minimum distance between the given pair of edges.
// If one edge crosses the antipodal reflection of the other, the distance is pi. | [
"updateEdgePairMaxDistance",
"reports",
"the",
"minimum",
"distance",
"between",
"the",
"given",
"pair",
"of",
"edges",
".",
"If",
"one",
"edge",
"crosses",
"the",
"antipodal",
"reflection",
"of",
"the",
"other",
"the",
"distance",
"is",
"pi",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_distances.go#L324-L343 |
150,064 | golang/geo | s2/contains_point_query.go | NewContainsPointQuery | func NewContainsPointQuery(index *ShapeIndex, model VertexModel) *ContainsPointQuery {
return &ContainsPointQuery{
index: index,
model: model,
iter: index.Iterator(),
}
} | go | func NewContainsPointQuery(index *ShapeIndex, model VertexModel) *ContainsPointQuery {
return &ContainsPointQuery{
index: index,
model: model,
iter: index.Iterator(),
}
} | [
"func",
"NewContainsPointQuery",
"(",
"index",
"*",
"ShapeIndex",
",",
"model",
"VertexModel",
")",
"*",
"ContainsPointQuery",
"{",
"return",
"&",
"ContainsPointQuery",
"{",
"index",
":",
"index",
",",
"model",
":",
"model",
",",
"iter",
":",
"index",
".",
"Iterator",
"(",
")",
",",
"}",
"\n",
"}"
] | // NewContainsPointQuery creates a new instance of the ContainsPointQuery for the index
// and given vertex model choice. | [
"NewContainsPointQuery",
"creates",
"a",
"new",
"instance",
"of",
"the",
"ContainsPointQuery",
"for",
"the",
"index",
"and",
"given",
"vertex",
"model",
"choice",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/contains_point_query.go#L61-L67 |
150,065 | golang/geo | s2/contains_point_query.go | shapeContains | func (q *ContainsPointQuery) shapeContains(clipped *clippedShape, center, p Point) bool {
inside := clipped.containsCenter
numEdges := clipped.numEdges()
if numEdges <= 0 {
return inside
}
shape := q.index.Shape(clipped.shapeID)
if shape.Dimension() != 2 {
// Points and polylines can be ignored unless the vertex model is Closed.
if q.model != VertexModelClosed {
return false
}
// Otherwise, the point is contained if and only if it matches a vertex.
for _, edgeID := range clipped.edges {
edge := shape.Edge(edgeID)
if edge.V0 == p || edge.V1 == p {
return true
}
}
return false
}
// Test containment by drawing a line segment from the cell center to the
// given point and counting edge crossings.
crosser := NewEdgeCrosser(center, p)
for _, edgeID := range clipped.edges {
edge := shape.Edge(edgeID)
sign := crosser.CrossingSign(edge.V0, edge.V1)
if sign == DoNotCross {
continue
}
if sign == MaybeCross {
// For the Open and Closed models, check whether p is a vertex.
if q.model != VertexModelSemiOpen && (edge.V0 == p || edge.V1 == p) {
return (q.model == VertexModelClosed)
}
// C++ plays fast and loose with the int <-> bool conversions here.
if VertexCrossing(crosser.a, crosser.b, edge.V0, edge.V1) {
sign = Cross
} else {
sign = DoNotCross
}
}
inside = inside != (sign == Cross)
}
return inside
} | go | func (q *ContainsPointQuery) shapeContains(clipped *clippedShape, center, p Point) bool {
inside := clipped.containsCenter
numEdges := clipped.numEdges()
if numEdges <= 0 {
return inside
}
shape := q.index.Shape(clipped.shapeID)
if shape.Dimension() != 2 {
// Points and polylines can be ignored unless the vertex model is Closed.
if q.model != VertexModelClosed {
return false
}
// Otherwise, the point is contained if and only if it matches a vertex.
for _, edgeID := range clipped.edges {
edge := shape.Edge(edgeID)
if edge.V0 == p || edge.V1 == p {
return true
}
}
return false
}
// Test containment by drawing a line segment from the cell center to the
// given point and counting edge crossings.
crosser := NewEdgeCrosser(center, p)
for _, edgeID := range clipped.edges {
edge := shape.Edge(edgeID)
sign := crosser.CrossingSign(edge.V0, edge.V1)
if sign == DoNotCross {
continue
}
if sign == MaybeCross {
// For the Open and Closed models, check whether p is a vertex.
if q.model != VertexModelSemiOpen && (edge.V0 == p || edge.V1 == p) {
return (q.model == VertexModelClosed)
}
// C++ plays fast and loose with the int <-> bool conversions here.
if VertexCrossing(crosser.a, crosser.b, edge.V0, edge.V1) {
sign = Cross
} else {
sign = DoNotCross
}
}
inside = inside != (sign == Cross)
}
return inside
} | [
"func",
"(",
"q",
"*",
"ContainsPointQuery",
")",
"shapeContains",
"(",
"clipped",
"*",
"clippedShape",
",",
"center",
",",
"p",
"Point",
")",
"bool",
"{",
"inside",
":=",
"clipped",
".",
"containsCenter",
"\n",
"numEdges",
":=",
"clipped",
".",
"numEdges",
"(",
")",
"\n",
"if",
"numEdges",
"<=",
"0",
"{",
"return",
"inside",
"\n",
"}",
"\n\n",
"shape",
":=",
"q",
".",
"index",
".",
"Shape",
"(",
"clipped",
".",
"shapeID",
")",
"\n",
"if",
"shape",
".",
"Dimension",
"(",
")",
"!=",
"2",
"{",
"// Points and polylines can be ignored unless the vertex model is Closed.",
"if",
"q",
".",
"model",
"!=",
"VertexModelClosed",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"// Otherwise, the point is contained if and only if it matches a vertex.",
"for",
"_",
",",
"edgeID",
":=",
"range",
"clipped",
".",
"edges",
"{",
"edge",
":=",
"shape",
".",
"Edge",
"(",
"edgeID",
")",
"\n",
"if",
"edge",
".",
"V0",
"==",
"p",
"||",
"edge",
".",
"V1",
"==",
"p",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}",
"\n\n",
"// Test containment by drawing a line segment from the cell center to the",
"// given point and counting edge crossings.",
"crosser",
":=",
"NewEdgeCrosser",
"(",
"center",
",",
"p",
")",
"\n",
"for",
"_",
",",
"edgeID",
":=",
"range",
"clipped",
".",
"edges",
"{",
"edge",
":=",
"shape",
".",
"Edge",
"(",
"edgeID",
")",
"\n",
"sign",
":=",
"crosser",
".",
"CrossingSign",
"(",
"edge",
".",
"V0",
",",
"edge",
".",
"V1",
")",
"\n",
"if",
"sign",
"==",
"DoNotCross",
"{",
"continue",
"\n",
"}",
"\n",
"if",
"sign",
"==",
"MaybeCross",
"{",
"// For the Open and Closed models, check whether p is a vertex.",
"if",
"q",
".",
"model",
"!=",
"VertexModelSemiOpen",
"&&",
"(",
"edge",
".",
"V0",
"==",
"p",
"||",
"edge",
".",
"V1",
"==",
"p",
")",
"{",
"return",
"(",
"q",
".",
"model",
"==",
"VertexModelClosed",
")",
"\n",
"}",
"\n",
"// C++ plays fast and loose with the int <-> bool conversions here.",
"if",
"VertexCrossing",
"(",
"crosser",
".",
"a",
",",
"crosser",
".",
"b",
",",
"edge",
".",
"V0",
",",
"edge",
".",
"V1",
")",
"{",
"sign",
"=",
"Cross",
"\n",
"}",
"else",
"{",
"sign",
"=",
"DoNotCross",
"\n",
"}",
"\n",
"}",
"\n",
"inside",
"=",
"inside",
"!=",
"(",
"sign",
"==",
"Cross",
")",
"\n",
"}",
"\n\n",
"return",
"inside",
"\n",
"}"
] | // shapeContains reports whether the clippedShape from the iterator's center position contains
// the given point. | [
"shapeContains",
"reports",
"whether",
"the",
"clippedShape",
"from",
"the",
"iterator",
"s",
"center",
"position",
"contains",
"the",
"given",
"point",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/contains_point_query.go#L87-L136 |
150,066 | golang/geo | s2/contains_point_query.go | visitContainingShapes | func (q *ContainsPointQuery) visitContainingShapes(p Point, f shapeVisitorFunc) bool {
// This function returns false only if the algorithm terminates early
// because the visitor function returned false.
if !q.iter.LocatePoint(p) {
return true
}
cell := q.iter.IndexCell()
for _, clipped := range cell.shapes {
if q.shapeContains(clipped, q.iter.Center(), p) &&
!f(q.index.Shape(clipped.shapeID)) {
return false
}
}
return true
} | go | func (q *ContainsPointQuery) visitContainingShapes(p Point, f shapeVisitorFunc) bool {
// This function returns false only if the algorithm terminates early
// because the visitor function returned false.
if !q.iter.LocatePoint(p) {
return true
}
cell := q.iter.IndexCell()
for _, clipped := range cell.shapes {
if q.shapeContains(clipped, q.iter.Center(), p) &&
!f(q.index.Shape(clipped.shapeID)) {
return false
}
}
return true
} | [
"func",
"(",
"q",
"*",
"ContainsPointQuery",
")",
"visitContainingShapes",
"(",
"p",
"Point",
",",
"f",
"shapeVisitorFunc",
")",
"bool",
"{",
"// This function returns false only if the algorithm terminates early",
"// because the visitor function returned false.",
"if",
"!",
"q",
".",
"iter",
".",
"LocatePoint",
"(",
"p",
")",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"cell",
":=",
"q",
".",
"iter",
".",
"IndexCell",
"(",
")",
"\n",
"for",
"_",
",",
"clipped",
":=",
"range",
"cell",
".",
"shapes",
"{",
"if",
"q",
".",
"shapeContains",
"(",
"clipped",
",",
"q",
".",
"iter",
".",
"Center",
"(",
")",
",",
"p",
")",
"&&",
"!",
"f",
"(",
"q",
".",
"index",
".",
"Shape",
"(",
"clipped",
".",
"shapeID",
")",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] | // visitContainingShapes visits all shapes in the given index that contain the
// given point p, terminating early if the given visitor function returns false,
// in which case visitContainingShapes returns false. Each shape is
// visited at most once. | [
"visitContainingShapes",
"visits",
"all",
"shapes",
"in",
"the",
"given",
"index",
"that",
"contain",
"the",
"given",
"point",
"p",
"terminating",
"early",
"if",
"the",
"given",
"visitor",
"function",
"returns",
"false",
"in",
"which",
"case",
"visitContainingShapes",
"returns",
"false",
".",
"Each",
"shape",
"is",
"visited",
"at",
"most",
"once",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/contains_point_query.go#L161-L176 |
150,067 | golang/geo | s2/contains_point_query.go | ContainingShapes | func (q *ContainsPointQuery) ContainingShapes(p Point) []Shape {
var shapes []Shape
q.visitContainingShapes(p, func(shape Shape) bool {
shapes = append(shapes, shape)
return true
})
return shapes
} | go | func (q *ContainsPointQuery) ContainingShapes(p Point) []Shape {
var shapes []Shape
q.visitContainingShapes(p, func(shape Shape) bool {
shapes = append(shapes, shape)
return true
})
return shapes
} | [
"func",
"(",
"q",
"*",
"ContainsPointQuery",
")",
"ContainingShapes",
"(",
"p",
"Point",
")",
"[",
"]",
"Shape",
"{",
"var",
"shapes",
"[",
"]",
"Shape",
"\n",
"q",
".",
"visitContainingShapes",
"(",
"p",
",",
"func",
"(",
"shape",
"Shape",
")",
"bool",
"{",
"shapes",
"=",
"append",
"(",
"shapes",
",",
"shape",
")",
"\n",
"return",
"true",
"\n",
"}",
")",
"\n",
"return",
"shapes",
"\n",
"}"
] | // ContainingShapes returns a slice of all shapes that contain the given point. | [
"ContainingShapes",
"returns",
"a",
"slice",
"of",
"all",
"shapes",
"that",
"contain",
"the",
"given",
"point",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/contains_point_query.go#L179-L186 |
150,068 | golang/geo | s2/cellid.go | CellIDFromToken | func CellIDFromToken(s string) CellID {
if len(s) > 16 {
return CellID(0)
}
n, err := strconv.ParseUint(s, 16, 64)
if err != nil {
return CellID(0)
}
// Equivalent to right-padding string with zeros to 16 characters.
if len(s) < 16 {
n = n << (4 * uint(16-len(s)))
}
return CellID(n)
} | go | func CellIDFromToken(s string) CellID {
if len(s) > 16 {
return CellID(0)
}
n, err := strconv.ParseUint(s, 16, 64)
if err != nil {
return CellID(0)
}
// Equivalent to right-padding string with zeros to 16 characters.
if len(s) < 16 {
n = n << (4 * uint(16-len(s)))
}
return CellID(n)
} | [
"func",
"CellIDFromToken",
"(",
"s",
"string",
")",
"CellID",
"{",
"if",
"len",
"(",
"s",
")",
">",
"16",
"{",
"return",
"CellID",
"(",
"0",
")",
"\n",
"}",
"\n",
"n",
",",
"err",
":=",
"strconv",
".",
"ParseUint",
"(",
"s",
",",
"16",
",",
"64",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"CellID",
"(",
"0",
")",
"\n",
"}",
"\n",
"// Equivalent to right-padding string with zeros to 16 characters.",
"if",
"len",
"(",
"s",
")",
"<",
"16",
"{",
"n",
"=",
"n",
"<<",
"(",
"4",
"*",
"uint",
"(",
"16",
"-",
"len",
"(",
"s",
")",
")",
")",
"\n",
"}",
"\n",
"return",
"CellID",
"(",
"n",
")",
"\n",
"}"
] | // CellIDFromToken returns a cell given a hex-encoded string of its uint64 ID. | [
"CellIDFromToken",
"returns",
"a",
"cell",
"given",
"a",
"hex",
"-",
"encoded",
"string",
"of",
"its",
"uint64",
"ID",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L116-L129 |
150,069 | golang/geo | s2/cellid.go | ToToken | func (ci CellID) ToToken() string {
s := strings.TrimRight(fmt.Sprintf("%016x", uint64(ci)), "0")
if len(s) == 0 {
return "X"
}
return s
} | go | func (ci CellID) ToToken() string {
s := strings.TrimRight(fmt.Sprintf("%016x", uint64(ci)), "0")
if len(s) == 0 {
return "X"
}
return s
} | [
"func",
"(",
"ci",
"CellID",
")",
"ToToken",
"(",
")",
"string",
"{",
"s",
":=",
"strings",
".",
"TrimRight",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"uint64",
"(",
"ci",
")",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"s",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"s",
"\n",
"}"
] | // ToToken returns a hex-encoded string of the uint64 cell id, with leading
// zeros included but trailing zeros stripped. | [
"ToToken",
"returns",
"a",
"hex",
"-",
"encoded",
"string",
"of",
"the",
"uint64",
"cell",
"id",
"with",
"leading",
"zeros",
"included",
"but",
"trailing",
"zeros",
"stripped",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L133-L139 |
150,070 | golang/geo | s2/cellid.go | Parent | func (ci CellID) Parent(level int) CellID {
lsb := lsbForLevel(level)
return CellID((uint64(ci) & -lsb) | lsb)
} | go | func (ci CellID) Parent(level int) CellID {
lsb := lsbForLevel(level)
return CellID((uint64(ci) & -lsb) | lsb)
} | [
"func",
"(",
"ci",
"CellID",
")",
"Parent",
"(",
"level",
"int",
")",
"CellID",
"{",
"lsb",
":=",
"lsbForLevel",
"(",
"level",
")",
"\n",
"return",
"CellID",
"(",
"(",
"uint64",
"(",
"ci",
")",
"&",
"-",
"lsb",
")",
"|",
"lsb",
")",
"\n",
"}"
] | // Parent returns the cell at the given level, which must be no greater than the current level. | [
"Parent",
"returns",
"the",
"cell",
"at",
"the",
"given",
"level",
"which",
"must",
"be",
"no",
"greater",
"than",
"the",
"current",
"level",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L174-L177 |
150,071 | golang/geo | s2/cellid.go | Children | func (ci CellID) Children() [4]CellID {
var ch [4]CellID
lsb := CellID(ci.lsb())
ch[0] = ci - lsb + lsb>>2
lsb >>= 1
ch[1] = ch[0] + lsb
ch[2] = ch[1] + lsb
ch[3] = ch[2] + lsb
return ch
} | go | func (ci CellID) Children() [4]CellID {
var ch [4]CellID
lsb := CellID(ci.lsb())
ch[0] = ci - lsb + lsb>>2
lsb >>= 1
ch[1] = ch[0] + lsb
ch[2] = ch[1] + lsb
ch[3] = ch[2] + lsb
return ch
} | [
"func",
"(",
"ci",
"CellID",
")",
"Children",
"(",
")",
"[",
"4",
"]",
"CellID",
"{",
"var",
"ch",
"[",
"4",
"]",
"CellID",
"\n",
"lsb",
":=",
"CellID",
"(",
"ci",
".",
"lsb",
"(",
")",
")",
"\n",
"ch",
"[",
"0",
"]",
"=",
"ci",
"-",
"lsb",
"+",
"lsb",
">>",
"2",
"\n",
"lsb",
">>=",
"1",
"\n",
"ch",
"[",
"1",
"]",
"=",
"ch",
"[",
"0",
"]",
"+",
"lsb",
"\n",
"ch",
"[",
"2",
"]",
"=",
"ch",
"[",
"1",
"]",
"+",
"lsb",
"\n",
"ch",
"[",
"3",
"]",
"=",
"ch",
"[",
"2",
"]",
"+",
"lsb",
"\n",
"return",
"ch",
"\n",
"}"
] | // Children returns the four immediate children of this cell.
// If ci is a leaf cell, it returns four identical cells that are not the children. | [
"Children",
"returns",
"the",
"four",
"immediate",
"children",
"of",
"this",
"cell",
".",
"If",
"ci",
"is",
"a",
"leaf",
"cell",
"it",
"returns",
"four",
"identical",
"cells",
"that",
"are",
"not",
"the",
"children",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L193-L202 |
150,072 | golang/geo | s2/cellid.go | EdgeNeighbors | func (ci CellID) EdgeNeighbors() [4]CellID {
level := ci.Level()
size := sizeIJ(level)
f, i, j, _ := ci.faceIJOrientation()
return [4]CellID{
cellIDFromFaceIJWrap(f, i, j-size).Parent(level),
cellIDFromFaceIJWrap(f, i+size, j).Parent(level),
cellIDFromFaceIJWrap(f, i, j+size).Parent(level),
cellIDFromFaceIJWrap(f, i-size, j).Parent(level),
}
} | go | func (ci CellID) EdgeNeighbors() [4]CellID {
level := ci.Level()
size := sizeIJ(level)
f, i, j, _ := ci.faceIJOrientation()
return [4]CellID{
cellIDFromFaceIJWrap(f, i, j-size).Parent(level),
cellIDFromFaceIJWrap(f, i+size, j).Parent(level),
cellIDFromFaceIJWrap(f, i, j+size).Parent(level),
cellIDFromFaceIJWrap(f, i-size, j).Parent(level),
}
} | [
"func",
"(",
"ci",
"CellID",
")",
"EdgeNeighbors",
"(",
")",
"[",
"4",
"]",
"CellID",
"{",
"level",
":=",
"ci",
".",
"Level",
"(",
")",
"\n",
"size",
":=",
"sizeIJ",
"(",
"level",
")",
"\n",
"f",
",",
"i",
",",
"j",
",",
"_",
":=",
"ci",
".",
"faceIJOrientation",
"(",
")",
"\n",
"return",
"[",
"4",
"]",
"CellID",
"{",
"cellIDFromFaceIJWrap",
"(",
"f",
",",
"i",
",",
"j",
"-",
"size",
")",
".",
"Parent",
"(",
"level",
")",
",",
"cellIDFromFaceIJWrap",
"(",
"f",
",",
"i",
"+",
"size",
",",
"j",
")",
".",
"Parent",
"(",
"level",
")",
",",
"cellIDFromFaceIJWrap",
"(",
"f",
",",
"i",
",",
"j",
"+",
"size",
")",
".",
"Parent",
"(",
"level",
")",
",",
"cellIDFromFaceIJWrap",
"(",
"f",
",",
"i",
"-",
"size",
",",
"j",
")",
".",
"Parent",
"(",
"level",
")",
",",
"}",
"\n",
"}"
] | // EdgeNeighbors returns the four cells that are adjacent across the cell's four edges.
// Edges 0, 1, 2, 3 are in the down, right, up, left directions in the face space.
// All neighbors are guaranteed to be distinct. | [
"EdgeNeighbors",
"returns",
"the",
"four",
"cells",
"that",
"are",
"adjacent",
"across",
"the",
"cell",
"s",
"four",
"edges",
".",
"Edges",
"0",
"1",
"2",
"3",
"are",
"in",
"the",
"down",
"right",
"up",
"left",
"directions",
"in",
"the",
"face",
"space",
".",
"All",
"neighbors",
"are",
"guaranteed",
"to",
"be",
"distinct",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L211-L221 |
150,073 | golang/geo | s2/cellid.go | Contains | func (ci CellID) Contains(oci CellID) bool {
return uint64(ci.RangeMin()) <= uint64(oci) && uint64(oci) <= uint64(ci.RangeMax())
} | go | func (ci CellID) Contains(oci CellID) bool {
return uint64(ci.RangeMin()) <= uint64(oci) && uint64(oci) <= uint64(ci.RangeMax())
} | [
"func",
"(",
"ci",
"CellID",
")",
"Contains",
"(",
"oci",
"CellID",
")",
"bool",
"{",
"return",
"uint64",
"(",
"ci",
".",
"RangeMin",
"(",
")",
")",
"<=",
"uint64",
"(",
"oci",
")",
"&&",
"uint64",
"(",
"oci",
")",
"<=",
"uint64",
"(",
"ci",
".",
"RangeMax",
"(",
")",
")",
"\n",
"}"
] | // Contains returns true iff the CellID contains oci. | [
"Contains",
"returns",
"true",
"iff",
"the",
"CellID",
"contains",
"oci",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L321-L323 |
150,074 | golang/geo | s2/cellid.go | Intersects | func (ci CellID) Intersects(oci CellID) bool {
return uint64(oci.RangeMin()) <= uint64(ci.RangeMax()) && uint64(oci.RangeMax()) >= uint64(ci.RangeMin())
} | go | func (ci CellID) Intersects(oci CellID) bool {
return uint64(oci.RangeMin()) <= uint64(ci.RangeMax()) && uint64(oci.RangeMax()) >= uint64(ci.RangeMin())
} | [
"func",
"(",
"ci",
"CellID",
")",
"Intersects",
"(",
"oci",
"CellID",
")",
"bool",
"{",
"return",
"uint64",
"(",
"oci",
".",
"RangeMin",
"(",
")",
")",
"<=",
"uint64",
"(",
"ci",
".",
"RangeMax",
"(",
")",
")",
"&&",
"uint64",
"(",
"oci",
".",
"RangeMax",
"(",
")",
")",
">=",
"uint64",
"(",
"ci",
".",
"RangeMin",
"(",
")",
")",
"\n",
"}"
] | // Intersects returns true iff the CellID intersects oci. | [
"Intersects",
"returns",
"true",
"iff",
"the",
"CellID",
"intersects",
"oci",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L326-L328 |
150,075 | golang/geo | s2/cellid.go | ChildBeginAtLevel | func (ci CellID) ChildBeginAtLevel(level int) CellID {
return CellID(uint64(ci) - ci.lsb() + lsbForLevel(level))
} | go | func (ci CellID) ChildBeginAtLevel(level int) CellID {
return CellID(uint64(ci) - ci.lsb() + lsbForLevel(level))
} | [
"func",
"(",
"ci",
"CellID",
")",
"ChildBeginAtLevel",
"(",
"level",
"int",
")",
"CellID",
"{",
"return",
"CellID",
"(",
"uint64",
"(",
"ci",
")",
"-",
"ci",
".",
"lsb",
"(",
")",
"+",
"lsbForLevel",
"(",
"level",
")",
")",
"\n",
"}"
] | // ChildBeginAtLevel returns the first cell in a traversal of children a given level deeper than this cell, in
// Hilbert curve order. The given level must be no smaller than the cell's level.
// See ChildBegin for example use. | [
"ChildBeginAtLevel",
"returns",
"the",
"first",
"cell",
"in",
"a",
"traversal",
"of",
"children",
"a",
"given",
"level",
"deeper",
"than",
"this",
"cell",
"in",
"Hilbert",
"curve",
"order",
".",
"The",
"given",
"level",
"must",
"be",
"no",
"smaller",
"than",
"the",
"cell",
"s",
"level",
".",
"See",
"ChildBegin",
"for",
"example",
"use",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L366-L368 |
150,076 | golang/geo | s2/cellid.go | ChildEnd | func (ci CellID) ChildEnd() CellID {
ol := ci.lsb()
return CellID(uint64(ci) + ol + ol>>2)
} | go | func (ci CellID) ChildEnd() CellID {
ol := ci.lsb()
return CellID(uint64(ci) + ol + ol>>2)
} | [
"func",
"(",
"ci",
"CellID",
")",
"ChildEnd",
"(",
")",
"CellID",
"{",
"ol",
":=",
"ci",
".",
"lsb",
"(",
")",
"\n",
"return",
"CellID",
"(",
"uint64",
"(",
"ci",
")",
"+",
"ol",
"+",
"ol",
">>",
"2",
")",
"\n",
"}"
] | // ChildEnd returns the first cell after a traversal of the children of this cell in Hilbert curve order.
// The returned cell may be invalid. | [
"ChildEnd",
"returns",
"the",
"first",
"cell",
"after",
"a",
"traversal",
"of",
"the",
"children",
"of",
"this",
"cell",
"in",
"Hilbert",
"curve",
"order",
".",
"The",
"returned",
"cell",
"may",
"be",
"invalid",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L372-L375 |
150,077 | golang/geo | s2/cellid.go | ChildEndAtLevel | func (ci CellID) ChildEndAtLevel(level int) CellID {
return CellID(uint64(ci) + ci.lsb() + lsbForLevel(level))
} | go | func (ci CellID) ChildEndAtLevel(level int) CellID {
return CellID(uint64(ci) + ci.lsb() + lsbForLevel(level))
} | [
"func",
"(",
"ci",
"CellID",
")",
"ChildEndAtLevel",
"(",
"level",
"int",
")",
"CellID",
"{",
"return",
"CellID",
"(",
"uint64",
"(",
"ci",
")",
"+",
"ci",
".",
"lsb",
"(",
")",
"+",
"lsbForLevel",
"(",
"level",
")",
")",
"\n",
"}"
] | // ChildEndAtLevel returns the first cell after the last child in a traversal of children a given level deeper
// than this cell, in Hilbert curve order.
// The given level must be no smaller than the cell's level.
// The returned cell may be invalid. | [
"ChildEndAtLevel",
"returns",
"the",
"first",
"cell",
"after",
"the",
"last",
"child",
"in",
"a",
"traversal",
"of",
"children",
"a",
"given",
"level",
"deeper",
"than",
"this",
"cell",
"in",
"Hilbert",
"curve",
"order",
".",
"The",
"given",
"level",
"must",
"be",
"no",
"smaller",
"than",
"the",
"cell",
"s",
"level",
".",
"The",
"returned",
"cell",
"may",
"be",
"invalid",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L381-L383 |
150,078 | golang/geo | s2/cellid.go | NextWrap | func (ci CellID) NextWrap() CellID {
n := ci.Next()
if uint64(n) < wrapOffset {
return n
}
return CellID(uint64(n) - wrapOffset)
} | go | func (ci CellID) NextWrap() CellID {
n := ci.Next()
if uint64(n) < wrapOffset {
return n
}
return CellID(uint64(n) - wrapOffset)
} | [
"func",
"(",
"ci",
"CellID",
")",
"NextWrap",
"(",
")",
"CellID",
"{",
"n",
":=",
"ci",
".",
"Next",
"(",
")",
"\n",
"if",
"uint64",
"(",
"n",
")",
"<",
"wrapOffset",
"{",
"return",
"n",
"\n",
"}",
"\n",
"return",
"CellID",
"(",
"uint64",
"(",
"n",
")",
"-",
"wrapOffset",
")",
"\n",
"}"
] | // NextWrap returns the next cell along the Hilbert curve, wrapping from last to
// first as necessary. This should not be used with ChildBegin and ChildEnd. | [
"NextWrap",
"returns",
"the",
"next",
"cell",
"along",
"the",
"Hilbert",
"curve",
"wrapping",
"from",
"last",
"to",
"first",
"as",
"necessary",
".",
"This",
"should",
"not",
"be",
"used",
"with",
"ChildBegin",
"and",
"ChildEnd",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L399-L405 |
150,079 | golang/geo | s2/cellid.go | PrevWrap | func (ci CellID) PrevWrap() CellID {
p := ci.Prev()
if uint64(p) < wrapOffset {
return p
}
return CellID(uint64(p) + wrapOffset)
} | go | func (ci CellID) PrevWrap() CellID {
p := ci.Prev()
if uint64(p) < wrapOffset {
return p
}
return CellID(uint64(p) + wrapOffset)
} | [
"func",
"(",
"ci",
"CellID",
")",
"PrevWrap",
"(",
")",
"CellID",
"{",
"p",
":=",
"ci",
".",
"Prev",
"(",
")",
"\n",
"if",
"uint64",
"(",
"p",
")",
"<",
"wrapOffset",
"{",
"return",
"p",
"\n",
"}",
"\n",
"return",
"CellID",
"(",
"uint64",
"(",
"p",
")",
"+",
"wrapOffset",
")",
"\n",
"}"
] | // PrevWrap returns the previous cell along the Hilbert curve, wrapping around from
// first to last as necessary. This should not be used with ChildBegin and ChildEnd. | [
"PrevWrap",
"returns",
"the",
"previous",
"cell",
"along",
"the",
"Hilbert",
"curve",
"wrapping",
"around",
"from",
"first",
"to",
"last",
"as",
"necessary",
".",
"This",
"should",
"not",
"be",
"used",
"with",
"ChildBegin",
"and",
"ChildEnd",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L409-L415 |
150,080 | golang/geo | s2/cellid.go | AdvanceWrap | func (ci CellID) AdvanceWrap(steps int64) CellID {
if steps == 0 {
return ci
}
// We clamp the number of steps if necessary to ensure that we do not
// advance past the End() or before the Begin() of this level.
shift := uint(2*(maxLevel-ci.Level()) + 1)
if steps < 0 {
if min := -int64(uint64(ci) >> shift); steps < min {
wrap := int64(wrapOffset >> shift)
steps %= wrap
if steps < min {
steps += wrap
}
}
} else {
// Unlike Advance(), we don't want to return End(level).
if max := int64((wrapOffset - uint64(ci)) >> shift); steps > max {
wrap := int64(wrapOffset >> shift)
steps %= wrap
if steps > max {
steps -= wrap
}
}
}
// If steps is negative, then shifting it left has undefined behavior.
// Cast to uint64 for a 2's complement answer.
return CellID(uint64(ci) + (uint64(steps) << shift))
} | go | func (ci CellID) AdvanceWrap(steps int64) CellID {
if steps == 0 {
return ci
}
// We clamp the number of steps if necessary to ensure that we do not
// advance past the End() or before the Begin() of this level.
shift := uint(2*(maxLevel-ci.Level()) + 1)
if steps < 0 {
if min := -int64(uint64(ci) >> shift); steps < min {
wrap := int64(wrapOffset >> shift)
steps %= wrap
if steps < min {
steps += wrap
}
}
} else {
// Unlike Advance(), we don't want to return End(level).
if max := int64((wrapOffset - uint64(ci)) >> shift); steps > max {
wrap := int64(wrapOffset >> shift)
steps %= wrap
if steps > max {
steps -= wrap
}
}
}
// If steps is negative, then shifting it left has undefined behavior.
// Cast to uint64 for a 2's complement answer.
return CellID(uint64(ci) + (uint64(steps) << shift))
} | [
"func",
"(",
"ci",
"CellID",
")",
"AdvanceWrap",
"(",
"steps",
"int64",
")",
"CellID",
"{",
"if",
"steps",
"==",
"0",
"{",
"return",
"ci",
"\n",
"}",
"\n\n",
"// We clamp the number of steps if necessary to ensure that we do not",
"// advance past the End() or before the Begin() of this level.",
"shift",
":=",
"uint",
"(",
"2",
"*",
"(",
"maxLevel",
"-",
"ci",
".",
"Level",
"(",
")",
")",
"+",
"1",
")",
"\n",
"if",
"steps",
"<",
"0",
"{",
"if",
"min",
":=",
"-",
"int64",
"(",
"uint64",
"(",
"ci",
")",
">>",
"shift",
")",
";",
"steps",
"<",
"min",
"{",
"wrap",
":=",
"int64",
"(",
"wrapOffset",
">>",
"shift",
")",
"\n",
"steps",
"%=",
"wrap",
"\n",
"if",
"steps",
"<",
"min",
"{",
"steps",
"+=",
"wrap",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"else",
"{",
"// Unlike Advance(), we don't want to return End(level).",
"if",
"max",
":=",
"int64",
"(",
"(",
"wrapOffset",
"-",
"uint64",
"(",
"ci",
")",
")",
">>",
"shift",
")",
";",
"steps",
">",
"max",
"{",
"wrap",
":=",
"int64",
"(",
"wrapOffset",
">>",
"shift",
")",
"\n",
"steps",
"%=",
"wrap",
"\n",
"if",
"steps",
">",
"max",
"{",
"steps",
"-=",
"wrap",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"// If steps is negative, then shifting it left has undefined behavior.",
"// Cast to uint64 for a 2's complement answer.",
"return",
"CellID",
"(",
"uint64",
"(",
"ci",
")",
"+",
"(",
"uint64",
"(",
"steps",
")",
"<<",
"shift",
")",
")",
"\n",
"}"
] | // AdvanceWrap advances or retreats the indicated number of steps along the
// Hilbert curve at the current level and returns the new position. The
// position wraps between the first and last faces as necessary. | [
"AdvanceWrap",
"advances",
"or",
"retreats",
"the",
"indicated",
"number",
"of",
"steps",
"along",
"the",
"Hilbert",
"curve",
"at",
"the",
"current",
"level",
"and",
"returns",
"the",
"new",
"position",
".",
"The",
"position",
"wraps",
"between",
"the",
"first",
"and",
"last",
"faces",
"as",
"necessary",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L420-L450 |
150,081 | golang/geo | s2/cellid.go | Encode | func (ci CellID) Encode(w io.Writer) error {
e := &encoder{w: w}
ci.encode(e)
return e.err
} | go | func (ci CellID) Encode(w io.Writer) error {
e := &encoder{w: w}
ci.encode(e)
return e.err
} | [
"func",
"(",
"ci",
"CellID",
")",
"Encode",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"e",
":=",
"&",
"encoder",
"{",
"w",
":",
"w",
"}",
"\n",
"ci",
".",
"encode",
"(",
"e",
")",
"\n",
"return",
"e",
".",
"err",
"\n",
"}"
] | // Encode encodes the CellID. | [
"Encode",
"encodes",
"the",
"CellID",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L453-L457 |
150,082 | golang/geo | s2/cellid.go | Decode | func (ci *CellID) Decode(r io.Reader) error {
d := &decoder{r: asByteReader(r)}
ci.decode(d)
return d.err
} | go | func (ci *CellID) Decode(r io.Reader) error {
d := &decoder{r: asByteReader(r)}
ci.decode(d)
return d.err
} | [
"func",
"(",
"ci",
"*",
"CellID",
")",
"Decode",
"(",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"d",
":=",
"&",
"decoder",
"{",
"r",
":",
"asByteReader",
"(",
"r",
")",
"}",
"\n",
"ci",
".",
"decode",
"(",
"d",
")",
"\n",
"return",
"d",
".",
"err",
"\n",
"}"
] | // Decode encodes the CellID. | [
"Decode",
"encodes",
"the",
"CellID",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L464-L468 |
150,083 | golang/geo | s2/cellid.go | rawPoint | func (ci CellID) rawPoint() r3.Vector {
face, si, ti := ci.faceSiTi()
return faceUVToXYZ(face, stToUV((0.5/maxSize)*float64(si)), stToUV((0.5/maxSize)*float64(ti)))
} | go | func (ci CellID) rawPoint() r3.Vector {
face, si, ti := ci.faceSiTi()
return faceUVToXYZ(face, stToUV((0.5/maxSize)*float64(si)), stToUV((0.5/maxSize)*float64(ti)))
} | [
"func",
"(",
"ci",
"CellID",
")",
"rawPoint",
"(",
")",
"r3",
".",
"Vector",
"{",
"face",
",",
"si",
",",
"ti",
":=",
"ci",
".",
"faceSiTi",
"(",
")",
"\n",
"return",
"faceUVToXYZ",
"(",
"face",
",",
"stToUV",
"(",
"(",
"0.5",
"/",
"maxSize",
")",
"*",
"float64",
"(",
"si",
")",
")",
",",
"stToUV",
"(",
"(",
"0.5",
"/",
"maxSize",
")",
"*",
"float64",
"(",
"ti",
")",
")",
")",
"\n",
"}"
] | // rawPoint returns an unnormalized r3 vector from the origin through the center
// of the s2 cell on the sphere. | [
"rawPoint",
"returns",
"an",
"unnormalized",
"r3",
"vector",
"from",
"the",
"origin",
"through",
"the",
"center",
"of",
"the",
"s2",
"cell",
"on",
"the",
"sphere",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L486-L489 |
150,084 | golang/geo | s2/cellid.go | faceIJOrientation | func (ci CellID) faceIJOrientation() (f, i, j, orientation int) {
f = ci.Face()
orientation = f & swapMask
nbits := maxLevel - 7*lookupBits // first iteration
// Each iteration maps 8 bits of the Hilbert curve position into
// 4 bits of "i" and "j". The lookup table transforms a key of the
// form "ppppppppoo" to a value of the form "iiiijjjjoo", where the
// letters [ijpo] represents bits of "i", "j", the Hilbert curve
// position, and the Hilbert curve orientation respectively.
//
// On the first iteration we need to be careful to clear out the bits
// representing the cube face.
for k := 7; k >= 0; k-- {
orientation += (int(uint64(ci)>>uint64(k*2*lookupBits+1)) & ((1 << uint(2*nbits)) - 1)) << 2
orientation = lookupIJ[orientation]
i += (orientation >> (lookupBits + 2)) << uint(k*lookupBits)
j += ((orientation >> 2) & ((1 << lookupBits) - 1)) << uint(k*lookupBits)
orientation &= (swapMask | invertMask)
nbits = lookupBits // following iterations
}
// The position of a non-leaf cell at level "n" consists of a prefix of
// 2*n bits that identifies the cell, followed by a suffix of
// 2*(maxLevel-n)+1 bits of the form 10*. If n==maxLevel, the suffix is
// just "1" and has no effect. Otherwise, it consists of "10", followed
// by (maxLevel-n-1) repetitions of "00", followed by "0". The "10" has
// no effect, while each occurrence of "00" has the effect of reversing
// the swapMask bit.
if ci.lsb()&0x1111111111111110 != 0 {
orientation ^= swapMask
}
return
} | go | func (ci CellID) faceIJOrientation() (f, i, j, orientation int) {
f = ci.Face()
orientation = f & swapMask
nbits := maxLevel - 7*lookupBits // first iteration
// Each iteration maps 8 bits of the Hilbert curve position into
// 4 bits of "i" and "j". The lookup table transforms a key of the
// form "ppppppppoo" to a value of the form "iiiijjjjoo", where the
// letters [ijpo] represents bits of "i", "j", the Hilbert curve
// position, and the Hilbert curve orientation respectively.
//
// On the first iteration we need to be careful to clear out the bits
// representing the cube face.
for k := 7; k >= 0; k-- {
orientation += (int(uint64(ci)>>uint64(k*2*lookupBits+1)) & ((1 << uint(2*nbits)) - 1)) << 2
orientation = lookupIJ[orientation]
i += (orientation >> (lookupBits + 2)) << uint(k*lookupBits)
j += ((orientation >> 2) & ((1 << lookupBits) - 1)) << uint(k*lookupBits)
orientation &= (swapMask | invertMask)
nbits = lookupBits // following iterations
}
// The position of a non-leaf cell at level "n" consists of a prefix of
// 2*n bits that identifies the cell, followed by a suffix of
// 2*(maxLevel-n)+1 bits of the form 10*. If n==maxLevel, the suffix is
// just "1" and has no effect. Otherwise, it consists of "10", followed
// by (maxLevel-n-1) repetitions of "00", followed by "0". The "10" has
// no effect, while each occurrence of "00" has the effect of reversing
// the swapMask bit.
if ci.lsb()&0x1111111111111110 != 0 {
orientation ^= swapMask
}
return
} | [
"func",
"(",
"ci",
"CellID",
")",
"faceIJOrientation",
"(",
")",
"(",
"f",
",",
"i",
",",
"j",
",",
"orientation",
"int",
")",
"{",
"f",
"=",
"ci",
".",
"Face",
"(",
")",
"\n",
"orientation",
"=",
"f",
"&",
"swapMask",
"\n",
"nbits",
":=",
"maxLevel",
"-",
"7",
"*",
"lookupBits",
"// first iteration",
"\n\n",
"// Each iteration maps 8 bits of the Hilbert curve position into",
"// 4 bits of \"i\" and \"j\". The lookup table transforms a key of the",
"// form \"ppppppppoo\" to a value of the form \"iiiijjjjoo\", where the",
"// letters [ijpo] represents bits of \"i\", \"j\", the Hilbert curve",
"// position, and the Hilbert curve orientation respectively.",
"//",
"// On the first iteration we need to be careful to clear out the bits",
"// representing the cube face.",
"for",
"k",
":=",
"7",
";",
"k",
">=",
"0",
";",
"k",
"--",
"{",
"orientation",
"+=",
"(",
"int",
"(",
"uint64",
"(",
"ci",
")",
">>",
"uint64",
"(",
"k",
"*",
"2",
"*",
"lookupBits",
"+",
"1",
")",
")",
"&",
"(",
"(",
"1",
"<<",
"uint",
"(",
"2",
"*",
"nbits",
")",
")",
"-",
"1",
")",
")",
"<<",
"2",
"\n",
"orientation",
"=",
"lookupIJ",
"[",
"orientation",
"]",
"\n",
"i",
"+=",
"(",
"orientation",
">>",
"(",
"lookupBits",
"+",
"2",
")",
")",
"<<",
"uint",
"(",
"k",
"*",
"lookupBits",
")",
"\n",
"j",
"+=",
"(",
"(",
"orientation",
">>",
"2",
")",
"&",
"(",
"(",
"1",
"<<",
"lookupBits",
")",
"-",
"1",
")",
")",
"<<",
"uint",
"(",
"k",
"*",
"lookupBits",
")",
"\n",
"orientation",
"&=",
"(",
"swapMask",
"|",
"invertMask",
")",
"\n",
"nbits",
"=",
"lookupBits",
"// following iterations",
"\n",
"}",
"\n\n",
"// The position of a non-leaf cell at level \"n\" consists of a prefix of",
"// 2*n bits that identifies the cell, followed by a suffix of",
"// 2*(maxLevel-n)+1 bits of the form 10*. If n==maxLevel, the suffix is",
"// just \"1\" and has no effect. Otherwise, it consists of \"10\", followed",
"// by (maxLevel-n-1) repetitions of \"00\", followed by \"0\". The \"10\" has",
"// no effect, while each occurrence of \"00\" has the effect of reversing",
"// the swapMask bit.",
"if",
"ci",
".",
"lsb",
"(",
")",
"&",
"0x1111111111111110",
"!=",
"0",
"{",
"orientation",
"^=",
"swapMask",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] | // faceIJOrientation uses the global lookupIJ table to unfiddle the bits of ci. | [
"faceIJOrientation",
"uses",
"the",
"global",
"lookupIJ",
"table",
"to",
"unfiddle",
"the",
"bits",
"of",
"ci",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L506-L540 |
150,085 | golang/geo | s2/cellid.go | initLookupCell | func initLookupCell(level, i, j, origOrientation, pos, orientation int) {
if level == lookupBits {
ij := (i << lookupBits) + j
lookupPos[(ij<<2)+origOrientation] = (pos << 2) + orientation
lookupIJ[(pos<<2)+origOrientation] = (ij << 2) + orientation
return
}
level++
i <<= 1
j <<= 1
pos <<= 2
r := posToIJ[orientation]
initLookupCell(level, i+(r[0]>>1), j+(r[0]&1), origOrientation, pos, orientation^posToOrientation[0])
initLookupCell(level, i+(r[1]>>1), j+(r[1]&1), origOrientation, pos+1, orientation^posToOrientation[1])
initLookupCell(level, i+(r[2]>>1), j+(r[2]&1), origOrientation, pos+2, orientation^posToOrientation[2])
initLookupCell(level, i+(r[3]>>1), j+(r[3]&1), origOrientation, pos+3, orientation^posToOrientation[3])
} | go | func initLookupCell(level, i, j, origOrientation, pos, orientation int) {
if level == lookupBits {
ij := (i << lookupBits) + j
lookupPos[(ij<<2)+origOrientation] = (pos << 2) + orientation
lookupIJ[(pos<<2)+origOrientation] = (ij << 2) + orientation
return
}
level++
i <<= 1
j <<= 1
pos <<= 2
r := posToIJ[orientation]
initLookupCell(level, i+(r[0]>>1), j+(r[0]&1), origOrientation, pos, orientation^posToOrientation[0])
initLookupCell(level, i+(r[1]>>1), j+(r[1]&1), origOrientation, pos+1, orientation^posToOrientation[1])
initLookupCell(level, i+(r[2]>>1), j+(r[2]&1), origOrientation, pos+2, orientation^posToOrientation[2])
initLookupCell(level, i+(r[3]>>1), j+(r[3]&1), origOrientation, pos+3, orientation^posToOrientation[3])
} | [
"func",
"initLookupCell",
"(",
"level",
",",
"i",
",",
"j",
",",
"origOrientation",
",",
"pos",
",",
"orientation",
"int",
")",
"{",
"if",
"level",
"==",
"lookupBits",
"{",
"ij",
":=",
"(",
"i",
"<<",
"lookupBits",
")",
"+",
"j",
"\n",
"lookupPos",
"[",
"(",
"ij",
"<<",
"2",
")",
"+",
"origOrientation",
"]",
"=",
"(",
"pos",
"<<",
"2",
")",
"+",
"orientation",
"\n",
"lookupIJ",
"[",
"(",
"pos",
"<<",
"2",
")",
"+",
"origOrientation",
"]",
"=",
"(",
"ij",
"<<",
"2",
")",
"+",
"orientation",
"\n",
"return",
"\n",
"}",
"\n\n",
"level",
"++",
"\n",
"i",
"<<=",
"1",
"\n",
"j",
"<<=",
"1",
"\n",
"pos",
"<<=",
"2",
"\n",
"r",
":=",
"posToIJ",
"[",
"orientation",
"]",
"\n",
"initLookupCell",
"(",
"level",
",",
"i",
"+",
"(",
"r",
"[",
"0",
"]",
">>",
"1",
")",
",",
"j",
"+",
"(",
"r",
"[",
"0",
"]",
"&",
"1",
")",
",",
"origOrientation",
",",
"pos",
",",
"orientation",
"^",
"posToOrientation",
"[",
"0",
"]",
")",
"\n",
"initLookupCell",
"(",
"level",
",",
"i",
"+",
"(",
"r",
"[",
"1",
"]",
">>",
"1",
")",
",",
"j",
"+",
"(",
"r",
"[",
"1",
"]",
"&",
"1",
")",
",",
"origOrientation",
",",
"pos",
"+",
"1",
",",
"orientation",
"^",
"posToOrientation",
"[",
"1",
"]",
")",
"\n",
"initLookupCell",
"(",
"level",
",",
"i",
"+",
"(",
"r",
"[",
"2",
"]",
">>",
"1",
")",
",",
"j",
"+",
"(",
"r",
"[",
"2",
"]",
"&",
"1",
")",
",",
"origOrientation",
",",
"pos",
"+",
"2",
",",
"orientation",
"^",
"posToOrientation",
"[",
"2",
"]",
")",
"\n",
"initLookupCell",
"(",
"level",
",",
"i",
"+",
"(",
"r",
"[",
"3",
"]",
">>",
"1",
")",
",",
"j",
"+",
"(",
"r",
"[",
"3",
"]",
"&",
"1",
")",
",",
"origOrientation",
",",
"pos",
"+",
"3",
",",
"orientation",
"^",
"posToOrientation",
"[",
"3",
"]",
")",
"\n",
"}"
] | // initLookupCell initializes the lookupIJ table at init time. | [
"initLookupCell",
"initializes",
"the",
"lookupIJ",
"table",
"at",
"init",
"time",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L701-L718 |
150,086 | golang/geo | s2/cellid.go | CommonAncestorLevel | func (ci CellID) CommonAncestorLevel(other CellID) (level int, ok bool) {
bits := uint64(ci ^ other)
if bits < ci.lsb() {
bits = ci.lsb()
}
if bits < other.lsb() {
bits = other.lsb()
}
msbPos := findMSBSetNonZero64(bits)
if msbPos > 60 {
return 0, false
}
return (60 - msbPos) >> 1, true
} | go | func (ci CellID) CommonAncestorLevel(other CellID) (level int, ok bool) {
bits := uint64(ci ^ other)
if bits < ci.lsb() {
bits = ci.lsb()
}
if bits < other.lsb() {
bits = other.lsb()
}
msbPos := findMSBSetNonZero64(bits)
if msbPos > 60 {
return 0, false
}
return (60 - msbPos) >> 1, true
} | [
"func",
"(",
"ci",
"CellID",
")",
"CommonAncestorLevel",
"(",
"other",
"CellID",
")",
"(",
"level",
"int",
",",
"ok",
"bool",
")",
"{",
"bits",
":=",
"uint64",
"(",
"ci",
"^",
"other",
")",
"\n",
"if",
"bits",
"<",
"ci",
".",
"lsb",
"(",
")",
"{",
"bits",
"=",
"ci",
".",
"lsb",
"(",
")",
"\n",
"}",
"\n",
"if",
"bits",
"<",
"other",
".",
"lsb",
"(",
")",
"{",
"bits",
"=",
"other",
".",
"lsb",
"(",
")",
"\n",
"}",
"\n\n",
"msbPos",
":=",
"findMSBSetNonZero64",
"(",
"bits",
")",
"\n",
"if",
"msbPos",
">",
"60",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n",
"return",
"(",
"60",
"-",
"msbPos",
")",
">>",
"1",
",",
"true",
"\n",
"}"
] | // CommonAncestorLevel returns the level of the common ancestor of the two S2 CellIDs. | [
"CommonAncestorLevel",
"returns",
"the",
"level",
"of",
"the",
"common",
"ancestor",
"of",
"the",
"two",
"S2",
"CellIDs",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L721-L735 |
150,087 | golang/geo | s2/metric.go | Value | func (m Metric) Value(level int) float64 {
return math.Ldexp(m.Deriv, -m.Dim*level)
} | go | func (m Metric) Value(level int) float64 {
return math.Ldexp(m.Deriv, -m.Dim*level)
} | [
"func",
"(",
"m",
"Metric",
")",
"Value",
"(",
"level",
"int",
")",
"float64",
"{",
"return",
"math",
".",
"Ldexp",
"(",
"m",
".",
"Deriv",
",",
"-",
"m",
".",
"Dim",
"*",
"level",
")",
"\n",
"}"
] | // Value returns the value of the metric at the given level. | [
"Value",
"returns",
"the",
"value",
"of",
"the",
"metric",
"at",
"the",
"given",
"level",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/metric.go#L106-L108 |
150,088 | golang/geo | s2/util.go | roundAngle | func roundAngle(val s1.Angle) int32 {
if val < 0 {
return int32(val - 0.5)
}
return int32(val + 0.5)
} | go | func roundAngle(val s1.Angle) int32 {
if val < 0 {
return int32(val - 0.5)
}
return int32(val + 0.5)
} | [
"func",
"roundAngle",
"(",
"val",
"s1",
".",
"Angle",
")",
"int32",
"{",
"if",
"val",
"<",
"0",
"{",
"return",
"int32",
"(",
"val",
"-",
"0.5",
")",
"\n",
"}",
"\n",
"return",
"int32",
"(",
"val",
"+",
"0.5",
")",
"\n",
"}"
] | // roundAngle returns the value rounded to nearest as an int32.
// This does not match C++ exactly for the case of x.5. | [
"roundAngle",
"returns",
"the",
"value",
"rounded",
"to",
"nearest",
"as",
"an",
"int32",
".",
"This",
"does",
"not",
"match",
"C",
"++",
"exactly",
"for",
"the",
"case",
"of",
"x",
".",
"5",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L21-L26 |
150,089 | golang/geo | s2/util.go | minAngle | func minAngle(x s1.Angle, others ...s1.Angle) s1.Angle {
min := x
for _, y := range others {
if y < min {
min = y
}
}
return min
} | go | func minAngle(x s1.Angle, others ...s1.Angle) s1.Angle {
min := x
for _, y := range others {
if y < min {
min = y
}
}
return min
} | [
"func",
"minAngle",
"(",
"x",
"s1",
".",
"Angle",
",",
"others",
"...",
"s1",
".",
"Angle",
")",
"s1",
".",
"Angle",
"{",
"min",
":=",
"x",
"\n",
"for",
"_",
",",
"y",
":=",
"range",
"others",
"{",
"if",
"y",
"<",
"min",
"{",
"min",
"=",
"y",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"min",
"\n",
"}"
] | // minAngle returns the smallest of the given values. | [
"minAngle",
"returns",
"the",
"smallest",
"of",
"the",
"given",
"values",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L29-L37 |
150,090 | golang/geo | s2/util.go | maxAngle | func maxAngle(x s1.Angle, others ...s1.Angle) s1.Angle {
max := x
for _, y := range others {
if y > max {
max = y
}
}
return max
} | go | func maxAngle(x s1.Angle, others ...s1.Angle) s1.Angle {
max := x
for _, y := range others {
if y > max {
max = y
}
}
return max
} | [
"func",
"maxAngle",
"(",
"x",
"s1",
".",
"Angle",
",",
"others",
"...",
"s1",
".",
"Angle",
")",
"s1",
".",
"Angle",
"{",
"max",
":=",
"x",
"\n",
"for",
"_",
",",
"y",
":=",
"range",
"others",
"{",
"if",
"y",
">",
"max",
"{",
"max",
"=",
"y",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"max",
"\n",
"}"
] | // maxAngle returns the largest of the given values. | [
"maxAngle",
"returns",
"the",
"largest",
"of",
"the",
"given",
"values",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L40-L48 |
150,091 | golang/geo | s2/util.go | minChordAngle | func minChordAngle(x s1.ChordAngle, others ...s1.ChordAngle) s1.ChordAngle {
min := x
for _, y := range others {
if y < min {
min = y
}
}
return min
} | go | func minChordAngle(x s1.ChordAngle, others ...s1.ChordAngle) s1.ChordAngle {
min := x
for _, y := range others {
if y < min {
min = y
}
}
return min
} | [
"func",
"minChordAngle",
"(",
"x",
"s1",
".",
"ChordAngle",
",",
"others",
"...",
"s1",
".",
"ChordAngle",
")",
"s1",
".",
"ChordAngle",
"{",
"min",
":=",
"x",
"\n",
"for",
"_",
",",
"y",
":=",
"range",
"others",
"{",
"if",
"y",
"<",
"min",
"{",
"min",
"=",
"y",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"min",
"\n",
"}"
] | // minChordAngle returns the smallest of the given values. | [
"minChordAngle",
"returns",
"the",
"smallest",
"of",
"the",
"given",
"values",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L51-L59 |
150,092 | golang/geo | s2/util.go | maxChordAngle | func maxChordAngle(x s1.ChordAngle, others ...s1.ChordAngle) s1.ChordAngle {
max := x
for _, y := range others {
if y > max {
max = y
}
}
return max
} | go | func maxChordAngle(x s1.ChordAngle, others ...s1.ChordAngle) s1.ChordAngle {
max := x
for _, y := range others {
if y > max {
max = y
}
}
return max
} | [
"func",
"maxChordAngle",
"(",
"x",
"s1",
".",
"ChordAngle",
",",
"others",
"...",
"s1",
".",
"ChordAngle",
")",
"s1",
".",
"ChordAngle",
"{",
"max",
":=",
"x",
"\n",
"for",
"_",
",",
"y",
":=",
"range",
"others",
"{",
"if",
"y",
">",
"max",
"{",
"max",
"=",
"y",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"max",
"\n",
"}"
] | // maxChordAngle returns the largest of the given values. | [
"maxChordAngle",
"returns",
"the",
"largest",
"of",
"the",
"given",
"values",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L62-L70 |
150,093 | golang/geo | s2/util.go | minFloat64 | func minFloat64(x float64, others ...float64) float64 {
min := x
for _, y := range others {
if y < min {
min = y
}
}
return min
} | go | func minFloat64(x float64, others ...float64) float64 {
min := x
for _, y := range others {
if y < min {
min = y
}
}
return min
} | [
"func",
"minFloat64",
"(",
"x",
"float64",
",",
"others",
"...",
"float64",
")",
"float64",
"{",
"min",
":=",
"x",
"\n",
"for",
"_",
",",
"y",
":=",
"range",
"others",
"{",
"if",
"y",
"<",
"min",
"{",
"min",
"=",
"y",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"min",
"\n",
"}"
] | // minFloat64 returns the smallest of the given values. | [
"minFloat64",
"returns",
"the",
"smallest",
"of",
"the",
"given",
"values",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L73-L81 |
150,094 | golang/geo | s2/util.go | maxFloat64 | func maxFloat64(x float64, others ...float64) float64 {
max := x
for _, y := range others {
if y > max {
max = y
}
}
return max
} | go | func maxFloat64(x float64, others ...float64) float64 {
max := x
for _, y := range others {
if y > max {
max = y
}
}
return max
} | [
"func",
"maxFloat64",
"(",
"x",
"float64",
",",
"others",
"...",
"float64",
")",
"float64",
"{",
"max",
":=",
"x",
"\n",
"for",
"_",
",",
"y",
":=",
"range",
"others",
"{",
"if",
"y",
">",
"max",
"{",
"max",
"=",
"y",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"max",
"\n",
"}"
] | // maxFloat64 returns the largest of the given values. | [
"maxFloat64",
"returns",
"the",
"largest",
"of",
"the",
"given",
"values",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L84-L92 |
150,095 | golang/geo | s2/util.go | minInt | func minInt(x int, others ...int) int {
min := x
for _, y := range others {
if y < min {
min = y
}
}
return min
} | go | func minInt(x int, others ...int) int {
min := x
for _, y := range others {
if y < min {
min = y
}
}
return min
} | [
"func",
"minInt",
"(",
"x",
"int",
",",
"others",
"...",
"int",
")",
"int",
"{",
"min",
":=",
"x",
"\n",
"for",
"_",
",",
"y",
":=",
"range",
"others",
"{",
"if",
"y",
"<",
"min",
"{",
"min",
"=",
"y",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"min",
"\n",
"}"
] | // minInt returns the smallest of the given values. | [
"minInt",
"returns",
"the",
"smallest",
"of",
"the",
"given",
"values",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L95-L103 |
150,096 | golang/geo | s2/util.go | maxInt | func maxInt(x int, others ...int) int {
max := x
for _, y := range others {
if y > max {
max = y
}
}
return max
} | go | func maxInt(x int, others ...int) int {
max := x
for _, y := range others {
if y > max {
max = y
}
}
return max
} | [
"func",
"maxInt",
"(",
"x",
"int",
",",
"others",
"...",
"int",
")",
"int",
"{",
"max",
":=",
"x",
"\n",
"for",
"_",
",",
"y",
":=",
"range",
"others",
"{",
"if",
"y",
">",
"max",
"{",
"max",
"=",
"y",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"max",
"\n",
"}"
] | // maxInt returns the largest of the given values. | [
"maxInt",
"returns",
"the",
"largest",
"of",
"the",
"given",
"values",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L106-L114 |
150,097 | golang/geo | s2/util.go | clampInt | func clampInt(x, min, max int) int {
if x < min {
return min
}
if x > max {
return max
}
return x
} | go | func clampInt(x, min, max int) int {
if x < min {
return min
}
if x > max {
return max
}
return x
} | [
"func",
"clampInt",
"(",
"x",
",",
"min",
",",
"max",
"int",
")",
"int",
"{",
"if",
"x",
"<",
"min",
"{",
"return",
"min",
"\n",
"}",
"\n",
"if",
"x",
">",
"max",
"{",
"return",
"max",
"\n",
"}",
"\n",
"return",
"x",
"\n",
"}"
] | // clampInt returns the number closest to x within the range min..max. | [
"clampInt",
"returns",
"the",
"number",
"closest",
"to",
"x",
"within",
"the",
"range",
"min",
"..",
"max",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L117-L125 |
150,098 | golang/geo | s2/regioncoverer.go | newCandidate | func (c *coverer) newCandidate(cell Cell) *candidate {
if !c.region.IntersectsCell(cell) {
return nil
}
cand := &candidate{cell: cell}
level := int(cell.level)
if level >= c.minLevel {
if c.interiorCovering {
if c.region.ContainsCell(cell) {
cand.terminal = true
} else if level+c.levelMod > c.maxLevel {
return nil
}
} else if level+c.levelMod > c.maxLevel || c.region.ContainsCell(cell) {
cand.terminal = true
}
}
return cand
} | go | func (c *coverer) newCandidate(cell Cell) *candidate {
if !c.region.IntersectsCell(cell) {
return nil
}
cand := &candidate{cell: cell}
level := int(cell.level)
if level >= c.minLevel {
if c.interiorCovering {
if c.region.ContainsCell(cell) {
cand.terminal = true
} else if level+c.levelMod > c.maxLevel {
return nil
}
} else if level+c.levelMod > c.maxLevel || c.region.ContainsCell(cell) {
cand.terminal = true
}
}
return cand
} | [
"func",
"(",
"c",
"*",
"coverer",
")",
"newCandidate",
"(",
"cell",
"Cell",
")",
"*",
"candidate",
"{",
"if",
"!",
"c",
".",
"region",
".",
"IntersectsCell",
"(",
"cell",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"cand",
":=",
"&",
"candidate",
"{",
"cell",
":",
"cell",
"}",
"\n",
"level",
":=",
"int",
"(",
"cell",
".",
"level",
")",
"\n",
"if",
"level",
">=",
"c",
".",
"minLevel",
"{",
"if",
"c",
".",
"interiorCovering",
"{",
"if",
"c",
".",
"region",
".",
"ContainsCell",
"(",
"cell",
")",
"{",
"cand",
".",
"terminal",
"=",
"true",
"\n",
"}",
"else",
"if",
"level",
"+",
"c",
".",
"levelMod",
">",
"c",
".",
"maxLevel",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"}",
"else",
"if",
"level",
"+",
"c",
".",
"levelMod",
">",
"c",
".",
"maxLevel",
"||",
"c",
".",
"region",
".",
"ContainsCell",
"(",
"cell",
")",
"{",
"cand",
".",
"terminal",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"cand",
"\n",
"}"
] | // newCandidate returns a new candidate with no children if the cell intersects the given region.
// The candidate is marked as terminal if it should not be expanded further. | [
"newCandidate",
"returns",
"a",
"new",
"candidate",
"with",
"no",
"children",
"if",
"the",
"cell",
"intersects",
"the",
"given",
"region",
".",
"The",
"candidate",
"is",
"marked",
"as",
"terminal",
"if",
"it",
"should",
"not",
"be",
"expanded",
"further",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L132-L150 |
150,099 | golang/geo | s2/regioncoverer.go | expandChildren | func (c *coverer) expandChildren(cand *candidate, cell Cell, numLevels int) int {
numLevels--
var numTerminals int
last := cell.id.ChildEnd()
for ci := cell.id.ChildBegin(); ci != last; ci = ci.Next() {
childCell := CellFromCellID(ci)
if numLevels > 0 {
if c.region.IntersectsCell(childCell) {
numTerminals += c.expandChildren(cand, childCell, numLevels)
}
continue
}
if child := c.newCandidate(childCell); child != nil {
cand.children = append(cand.children, child)
cand.numChildren++
if child.terminal {
numTerminals++
}
}
}
return numTerminals
} | go | func (c *coverer) expandChildren(cand *candidate, cell Cell, numLevels int) int {
numLevels--
var numTerminals int
last := cell.id.ChildEnd()
for ci := cell.id.ChildBegin(); ci != last; ci = ci.Next() {
childCell := CellFromCellID(ci)
if numLevels > 0 {
if c.region.IntersectsCell(childCell) {
numTerminals += c.expandChildren(cand, childCell, numLevels)
}
continue
}
if child := c.newCandidate(childCell); child != nil {
cand.children = append(cand.children, child)
cand.numChildren++
if child.terminal {
numTerminals++
}
}
}
return numTerminals
} | [
"func",
"(",
"c",
"*",
"coverer",
")",
"expandChildren",
"(",
"cand",
"*",
"candidate",
",",
"cell",
"Cell",
",",
"numLevels",
"int",
")",
"int",
"{",
"numLevels",
"--",
"\n",
"var",
"numTerminals",
"int",
"\n",
"last",
":=",
"cell",
".",
"id",
".",
"ChildEnd",
"(",
")",
"\n",
"for",
"ci",
":=",
"cell",
".",
"id",
".",
"ChildBegin",
"(",
")",
";",
"ci",
"!=",
"last",
";",
"ci",
"=",
"ci",
".",
"Next",
"(",
")",
"{",
"childCell",
":=",
"CellFromCellID",
"(",
"ci",
")",
"\n",
"if",
"numLevels",
">",
"0",
"{",
"if",
"c",
".",
"region",
".",
"IntersectsCell",
"(",
"childCell",
")",
"{",
"numTerminals",
"+=",
"c",
".",
"expandChildren",
"(",
"cand",
",",
"childCell",
",",
"numLevels",
")",
"\n",
"}",
"\n",
"continue",
"\n",
"}",
"\n",
"if",
"child",
":=",
"c",
".",
"newCandidate",
"(",
"childCell",
")",
";",
"child",
"!=",
"nil",
"{",
"cand",
".",
"children",
"=",
"append",
"(",
"cand",
".",
"children",
",",
"child",
")",
"\n",
"cand",
".",
"numChildren",
"++",
"\n",
"if",
"child",
".",
"terminal",
"{",
"numTerminals",
"++",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"numTerminals",
"\n",
"}"
] | // expandChildren populates the children of the candidate by expanding the given number of
// levels from the given cell. Returns the number of children that were marked "terminal". | [
"expandChildren",
"populates",
"the",
"children",
"of",
"the",
"candidate",
"by",
"expanding",
"the",
"given",
"number",
"of",
"levels",
"from",
"the",
"given",
"cell",
".",
"Returns",
"the",
"number",
"of",
"children",
"that",
"were",
"marked",
"terminal",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L154-L175 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.