/* At returns the list latitude,longitude in degrees or radians that is a
specified range and bearing from a given location.

    lat2, lon2  = geo.At( lat1, lon1, range, bearing )

*/
330991
func (ellipsoid Ellipsoid) At(lat1, lon1, distance, bearing float64) (lat2, lon2 float64) {

	if ellipsoid.Units == Degrees {
		lat1 = deg2rad(lat1)
		lon1 = deg2rad(lon1)
		bearing = deg2rad(bearing)
	}

	lat2, lon2 = ellipsoid.calculateTargetlocation(lat1, lon1, distance, bearing)

	if ellipsoid.LongitudeSymmetric == LongitudeIsSymmetric {
		if lon2 > pi {
			lon2 -= twopi
		}
	}
	if ellipsoid.LongitudeSymmetric == LongitudeNotSymmetric {
		if lon2 < 0.0 {
			lon2 += twopi
		}
	}

	if ellipsoid.Units == Degrees {
		lat2 = rad2deg(lat2)
		lon2 = rad2deg(lon2)
	}

	return
}
967570
func (p Point) EqualTo(other Point) bool {
	var (
		dlat = p.Latitude - other.Latitude
		dlng = p.Longitude - other.Longitude
	)

	for dlat < -180.0 {
		dlat += 360.0
	}
	for dlat > 180.0 {
		dlat -= 360.0
	}
	for dlng < -90.0 {
		dlng += 90.0
	}
	for dlng > 90.0 {
		dlng -= 90.0
	}

	return dlat == 0.0 && dlng == 0.0
}
873579
func (mat *MatMxN) At(row, col int) float32 {
	return mat.dat[col*mat.m+row]
}
849007
func (r Rope) At(idx int64) byte {
	if idx < 0 || idx >= r.Len() {
		panic("rope: index out of bounds")
	}
	return r.node.at(idx)
}
762555
func MercatorScaleFactor(degreesLatitude float64) float64 {
	if degreesLatitude < -90.0 || degreesLatitude > 90.0 {
		panic(fmt.Sprintf("geo: latitude out of range, given %f", degreesLatitude))
	}

	return 1.0 / math.Cos(degreesLatitude/180.0*math.Pi)
}
1021827
func (s Slice) At(index ValueLength) (Slice, error) {
	if !s.IsArray() {
		return nil, InvalidTypeError{"Expecting type Array"}
	}

	if result, err := s.getNth(index); err != nil {
		return nil, WithStack(err)
	} else {
		return result, nil
	}
}
724239
func (p *Point) PointDistance(p2 Point) float32 {
	return math.Sqrt(p.PointDistanceSquared(p2))
}
883526
func (l GPSPoint) Value() (driver.Value, error) {
	return fmt.Sprintf("(%s,%s)", strconv.FormatFloat(l.Latitude, 'f', -1, 64), strconv.FormatFloat(l.Longitude, 'f', -1, 64)), nil
}
1240666
func (surface *Surface) At(x, y int) color.Color {
	pix := surface.Pixels()
	i := int32(y)*surface.Pitch + int32(x)*int32(surface.Format.BytesPerPixel)
	switch surface.Format.Format {
	/*
		case PIXELFORMAT_ARGB8888:
			return color.RGBA{pix[i+3], pix[i], pix[i+1], pix[i+2]}
		case PIXELFORMAT_ABGR8888:
			return color.RGBA{pix[i], pix[i+3], pix[i+2], pix[i+1]}
	*/
	case PIXELFORMAT_RGB888:
		return color.RGBA{pix[i], pix[i+1], pix[i+2], 0xff}
	default:
		panic("Not implemented yet")
	}
}
699623
func atois(strs []string) ([]int, error) {
	var a []int
	for _, str := range strs {
		i, err := strconv.Atoi(str)
		if err != nil {
			return nil, err
		}
		a = append(a, i)
	}
	return a, nil
}
1004991
func Locations(data []byte, k uint) []uint64 {
	locs := make([]uint64, k)

	// calculate locations
	h := baseHashes(data)
	for i := uint(0); i < k; i++ {
		locs[i] = location(h, i)
	}

	return locs
}
834562
func Distance(p1, p2 orb.Point) float64 {
	dLat := deg2rad(p1[1] - p2[1])
	dLon := deg2rad(p1[0] - p2[0])

	dLon = math.Abs(dLon)
	if dLon > math.Pi {
		dLon = 2*math.Pi - dLon
	}

	// fast way using pythagorean theorem on an equirectangular projection
	x := dLon * math.Cos(deg2rad((p1[1]+p2[1])/2.0))
	return math.Sqrt(dLat*dLat+x*x) * orb.EarthRadius
}
1186638
func (p *V2) GetLocations() ([]common.Location, error) {
	p.RLock()
	defer p.RUnlock()
	if len(p.locations) == 0 {
		return nil, common.ErrNotFound
	}
	locations := make([]common.Location, len(p.locations))
	i := 0
	for _, location := range p.locations {
		locations[i] = location
		i++
	}

	return locations, nil
}
166132
func InterpolateAtDistance(ax s1.Angle, a, b Point) Point {
	aRad := ax.Radians()

	// Use PointCross to compute the tangent vector at A towards B. The
	// result is always perpendicular to A, even if A=B or A=-B, but it is not
	// necessarily unit length. (We effectively normalize it below.)
	normal := a.PointCross(b)
	tangent := normal.Vector.Cross(a.Vector)

	// Now compute the appropriate linear combination of A and "tangent". With
	// infinite precision the result would always be unit length, but we
	// normalize it anyway to ensure that the error is within acceptable bounds.
	// (Otherwise errors can build up when the result of one interpolation is
	// fed into another interpolation.)
	return Point{(a.Mul(math.Cos(aRad)).Add(tangent.Mul(math.Sin(aRad) / tangent.Norm()))).Normalize()}
}
106950
func (s GeoDistanceSort) GeoDistance(geoDistance string) GeoDistanceSort {
	s.geoDistance = &geoDistance
	return s
}
1093062
func (v ByteView) At(i int) byte {
	if v.b != nil {
		return v.b[i]
	}
	return v.s[i]
}
1293070
func Atan2(x, y float32) float32 {
	return float32(math.Atan2(float64(x), float64(y)))
}