// sets x,y on 3857 from long lat on 4326.  Allows for crossing 180.
352731
func (m map3857) point3857(p *Point) (err error) {
	// map crosses 180 and the point is to the right
	switch m.crossesCentral && p.Longitude > -180.0 && p.Longitude < 0.0 {
	case true:
		err = db.QueryRow(svgPointQuery, p.Longitude, p.Latitude, width3857-m.llx, m.yshift, m.dx, m.dx).Scan(&p.x, &p.y)
	case false:
		err = db.QueryRow(svgPointQuery, p.Longitude, p.Latitude, m.xshift, m.yshift, m.dx, m.dx).Scan(&p.x, &p.y)
	}

	return
}
611818
func (d *Datum) SetMysqlDecimal(b *MyDecimal) {
	d.k = KindMysqlDecimal
	d.x = b
}
556470
func (sp *SendLocation) SetLongitude(long float64) *SendLocation {
	sp.Longitude = long
	return sp
}
1151083
func bitmapSetRangeIgnoreN(bitmap []uint64, i, j uint64) {
	x := i >> 6
	y := (j - 1) >> 6
	var X uint64 = maxBitmap << (i % 64)
	var Y uint64 = maxBitmap >> (63 - ((j - 1) % 64))

	if x == y {
		bitmap[x] |= (X & Y)
	} else {
		bitmap[x] |= X
		for i := x + 1; i < y; i++ {
			bitmap[i] = maxBitmap
		}
		bitmap[y] |= Y
	}
}
1154125
func (m map3857) marker3857(marker *Marker) (err error) {
	// map crosses 180 and the point is to the right
	switch m.crossesCentral && marker.longitude > -180.0 && marker.longitude < 0.0 {
	case true:
		err = db.QueryRow(svgPointQuery, marker.longitude, marker.latitude, width3857-m.llx, m.yshift, m.dx, m.dx).Scan(&marker.x, &marker.y)
	case false:
		err = db.QueryRow(svgPointQuery, marker.longitude, marker.latitude, m.xshift, m.yshift, m.dx, m.dx).Scan(&marker.x, &marker.y)
	}

	return
}
553366
func Yn(n int, x float32) float32 {
	return engomath.Yn(n, x)
}
873850
func NewSetLocalPositionSetpoint(X float32, Y float32, Z float32, YAW float32, TARGET_SYSTEM uint8, TARGET_COMPONENT uint8, COORDINATE_FRAME uint8) *SetLocalPositionSetpoint {
	m := SetLocalPositionSetpoint{}
	m.X = X
	m.Y = Y
	m.Z = Z
	m.YAW = YAW
	m.TARGET_SYSTEM = TARGET_SYSTEM
	m.TARGET_COMPONENT = TARGET_COMPONENT
	m.COORDINATE_FRAME = COORDINATE_FRAME
	return &m
}
1321624
func (v *View) SetCursor(x, y int) error {
	maxX, maxY := v.Size()
	if x < 0 || x >= maxX || y < 0 || y >= maxY {
		return errors.New("invalid point")
	}
	v.cx = x
	v.cy = y
	return nil
}
588712
func Max(x, y float32) float32 {
	return float32(math.Max(float64(x), float64(y)))
}
1293070
func Atan2(x, y float32) float32 {
	return float32(math.Atan2(float64(x), float64(y)))
}
168412
func (x *Exif) LatLong() (lat, long float64, err error) {
	// All calls of x.Get might return an TagNotPresentError
	longTag, err := x.Get(FieldName("GPSLongitude"))
	if err != nil {
		return
	}
	ewTag, err := x.Get(FieldName("GPSLongitudeRef"))
	if err != nil {
		return
	}
	latTag, err := x.Get(FieldName("GPSLatitude"))
	if err != nil {
		return
	}
	nsTag, err := x.Get(FieldName("GPSLatitudeRef"))
	if err != nil {
		return
	}
	if long, err = tagDegrees(longTag); err != nil {
		return 0, 0, fmt.Errorf("Cannot parse longitude: %v", err)
	}
	if lat, err = tagDegrees(latTag); err != nil {
		return 0, 0, fmt.Errorf("Cannot parse latitude: %v", err)
	}
	ew, err := ewTag.StringVal()
	if err == nil && ew == "W" {
		long *= -1.0
	} else if err != nil {
		return 0, 0, fmt.Errorf("Cannot parse longitude: %v", err)
	}
	ns, err := nsTag.StringVal()
	if err == nil && ns == "S" {
		lat *= -1.0
	} else if err != nil {
		return 0, 0, fmt.Errorf("Cannot parse longitude: %v", err)
	}
	return lat, long, nil
}
419991
func NewGlobalPositionSetpointInt(LATITUDE int32, LONGITUDE int32, ALTITUDE int32, YAW int16, COORDINATE_FRAME uint8) *GlobalPositionSetpointInt {
	m := GlobalPositionSetpointInt{}
	m.LATITUDE = LATITUDE
	m.LONGITUDE = LONGITUDE
	m.ALTITUDE = ALTITUDE
	m.YAW = YAW
	m.COORDINATE_FRAME = COORDINATE_FRAME
	return &m
}
707716
func Min(x, y float32) float32 {
	return float32(math.Min(float64(x), float64(y)))
}
486034
func (s *SSD1306Driver) Set(x, y, c int) {
	s.buffer.SetPixel(x, y, c)
}
846254
func (s *Location) SetLongitude(v float64) *Location {
	s.Longitude = &v
	return s
}
307106
func FromXAxisAngle(angle float64) T {
	angle *= 0.5
	return T{math.Sin(angle), 0, 0, math.Cos(angle)}
}
124085
func (matrix *Matrix) TransformPoint(x, y *float64) {
	C.cairo_matrix_transform_point((*C.cairo_matrix_t)(unsafe.Pointer(matrix)), (*C.double)(unsafe.Pointer(x)), (*C.double)(unsafe.Pointer(y)))
}