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
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
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", "{",...
// 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", "longitudi...
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", "."...
// 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", ".", "...
// 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", ...
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....
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....
[ "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", ...
// 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...
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...
[ "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 retur...
// 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", ".", ...
// 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()}...
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()}...
[ "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 poin...
// 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})) == Cro...
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})) == Cro...
[ "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",...
// 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()}) { ...
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()}) { ...
[ "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...
// 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", ".",...
// 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", "ce...
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", "(", ")"...
// 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-epsilo...
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-epsilo...
[ "func", "(", "c", "Cap", ")", "ApproxEqual", "(", "other", "Cap", ")", "bool", "{", "const", "epsilon", "=", "1e-14", "\n", "r2", ":=", "float64", "(", "c", ".", "radius", ")", "\n", "otherR2", ":=", "float64", "(", "other", ".", "radius", ")", "\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 new...
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 new...
[ "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 ...
// 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", "b...
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(othe...
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(othe...
[ "func", "(", "c", "Cap", ")", "AddCap", "(", "other", "Cap", ")", "Cap", "{", "if", "c", ".", "IsEmpty", "(", ")", "{", "return", "other", "\n", "}", "\n", "if", "other", ".", "IsEmpty", "(", ")", "{", "return", "c", "\n", "}", "\n\n", "// We r...
// 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 inters...
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 inters...
[ "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", "+...
// 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", "++", "{"...
// 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()...
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()...
[ "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 cont...
// 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", ".", "Th...
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(...
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(...
[ "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", ",", ...
// 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", ".", ...
// 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", ")", "...
// 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", ...
// 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"...
// 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",...
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"...
// 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", ".", "I...
// 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", ...
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", "."...
// 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", "(", ...
// 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", "(", ")", "{",...
// 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",...
// 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...
// 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", ":...
// 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", "retu...
// 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 wher...
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 wher...
[ "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 ...
// 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", "(...
// 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...
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...
[ "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", ...
// 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", "a...
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...
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...
[ "func", "updateEndpoint", "(", "bound", "r1", ".", "Interval", ",", "highEndpoint", "bool", ",", "value", "float64", ")", "(", "r1", ".", "Interval", ",", "bool", ")", "{", "if", "!", "highEndpoint", "{", "if", "bound", ".", "Hi", "<", "value", "{", ...
// 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", "ret...
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 ...
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 ...
[ "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", ".", "RectFromPoi...
// 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", ":=", "clip...
// 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", "fu...
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 ed...
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 ed...
[ "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 h...
// 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 boun...
[ "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", ".", "Specificall...
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. (Th...
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. (Th...
[ "func", "stableSign", "(", "a", ",", "b", ",", "c", "Point", ")", "Direction", "{", "ab", ":=", "b", ".", "Sub", "(", "a", ".", "Vector", ")", "\n", "ab2", ":=", "ab", ".", "Norm2", "(", ")", "\n", "bc", ":=", "c", ".", "Sub", "(", "b", "."...
// 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 surfac...
[ "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", "...
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", "{", "retur...
// 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 expensiv...
[ "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", ...
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 recom...
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 recom...
[ "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.", ...
// 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", "ens...
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...
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...
[ "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(...
// 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 ...
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 ...
[ "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 tha...
// 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", ...
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", ":=...
// 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 <...
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 <...
[ "func", "triageCompareSin2Distance", "(", "x", ",", "y", "Point", ",", "r2", "float64", ")", "int", "{", "// Only valid for distance limits < 90 degrees.", "sin2XY", ",", "sin2XYError", ":=", "sin2Distance", "(", "x", ",", "y", ")", "\n", "sin2R", ":=", "r2", ...
// 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 sphe...
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 sphe...
[ "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 base...
// 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", "(", "...
// 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", "e...
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...
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...
[ "func", "UpdateMaxDistance", "(", "x", ",", "a", ",", "b", "Point", ",", "maxDist", "s1", ".", "ChordAngle", ")", "(", "s1", ".", "ChordAngle", ",", "bool", ")", "{", "dist", ":=", "maxChordAngle", "(", "ChordAngleBetweenPoints", "(", "x", ",", "a", ")...
// 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", ".", "Th...
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 P...
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 P...
[ "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", ...
// 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", "DistanceFr...
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)...
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)...
[ "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 perpendicu...
// 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...
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...
[ "func", "updateMinDistance", "(", "x", ",", "a", ",", "b", "Point", ",", "minDist", "s1", ".", "ChordAngle", ",", "alwaysUpdate", "bool", ")", "(", "s1", ".", "ChordAngle", ",", "bool", ")", "{", "if", "d", ",", "ok", ":=", "interiorDist", "(", "x", ...
// 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",...
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. ...
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. ...
[ "func", "updateEdgePairMinDistance", "(", "a0", ",", "a1", ",", "b0", ",", "b1", "Point", ",", "minDist", "s1", ".", "ChordAngle", ")", "(", "s1", ".", "ChordAngle", ",", "bool", ")", "{", "if", "minDist", "==", "0", "{", "return", "0", ",", "false",...
// 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", "==", "...
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 maximu...
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 maximu...
[ "func", "updateEdgePairMaxDistance", "(", "a0", ",", "a1", ",", "b0", ",", "b1", "Point", ",", "maxDist", "s1", ".", "ChordAngle", ")", "(", "s1", ".", "ChordAngle", ",", "bool", ")", "{", "if", "maxDist", "==", "s1", ".", "StraightChordAngle", "{", "r...
// 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", ".", "...
// 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 ve...
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 ve...
[ "func", "(", "q", "*", "ContainsPointQuery", ")", "shapeContains", "(", "clipped", "*", "clippedShape", ",", "center", ",", "p", "Point", ")", "bool", "{", "inside", ":=", "clipped", ".", "containsCenter", "\n", "numEdges", ":=", "clipped", ".", "numEdges", ...
// 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 {...
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 {...
[ "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", "!", ...
// 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", "visitContainingShap...
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"...
// 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...
// 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", ...
// 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",...
// 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), cellIDFromFaceIJ...
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), cellIDFromFaceIJ...
[ "func", "(", "ci", "CellID", ")", "EdgeNeighbors", "(", ")", "[", "4", "]", "CellID", "{", "level", ":=", "ci", ".", "Level", "(", ")", "\n", "size", ":=", "sizeIJ", "(", "level", ")", "\n", "f", ",", "i", ",", "j", ",", "_", ":=", "ci", ".",...
// 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",...
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", ".",...
// 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", ".", "R...
// 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",...
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",...
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", "(", ...
// 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", "(", ...
// 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); ...
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); ...
[ "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 th...
// 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...
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", "....
// 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", ")"...
// 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" t...
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" t...
[ "func", "(", "ci", "CellID", ")", "faceIJOrientation", "(", ")", "(", "f", ",", "i", ",", "j", ",", "orientation", "int", ")", "{", "f", "=", "ci", ".", "Face", "(", ")", "\n", "orientation", "=", "f", "&", "swapMask", "\n", "nbits", ":=", "maxLe...
// 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 := posToI...
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 := posToI...
[ "func", "initLookupCell", "(", "level", ",", "i", ",", "j", ",", "origOrientation", ",", "pos", ",", "orientation", "int", ")", "{", "if", "level", "==", "lookupBits", "{", "ij", ":=", "(", "i", "<<", "lookupBits", ")", "+", "j", "\n", "lookupPos", "...
// 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", "(", ")", "{"...
// 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",...
// 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",...
// 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", "{", ...
// 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", "{", ...
// 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"...
// 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"...
// 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", ...
// 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", ...
// 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.maxLeve...
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.maxLeve...
[ "func", "(", "c", "*", "coverer", ")", "newCandidate", "(", "cell", "Cell", ")", "*", "candidate", "{", "if", "!", "c", ".", "region", ".", "IntersectsCell", "(", "cell", ")", "{", "return", "nil", "\n", "}", "\n", "cand", ":=", "&", "candidate", "...
// 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) { numTerminal...
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) { numTerminal...
[ "func", "(", "c", "*", "coverer", ")", "expandChildren", "(", "cand", "*", "candidate", ",", "cell", "Cell", ",", "numLevels", "int", ")", "int", "{", "numLevels", "--", "\n", "var", "numTerminals", "int", "\n", "last", ":=", "cell", ".", "id", ".", ...
// 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