// Point is a helper to project an a point
548618
func Point(p orb.Point, proj orb.Projection) orb.Point {
	return proj(p)
}
1092762
func (p *Point) Normalize() (Point, float32) {
	if p.X == 0 && p.Y == 0 {
		return *p, 0
	}

	mag := math.Sqrt(p.X*p.X + p.Y*p.Y)
	unit := Point{p.X / mag, p.Y / mag}

	return unit, mag
}
1207528
func (p PostGISPoint) Value() (driver.Value, error) {
	return []byte(fmt.Sprintf("SRID=4326;POINT(%.8f %.8f)", p.Lon, p.Lat)), nil
}
436670
func (p *Point) format() string {
	if p.X == nil && p.Y == nil {
		return "(inf,inf)"
	}
	return fmt.Sprintf("(%s,%s)", hex.EncodeToString(p.X.Bytes()), hex.EncodeToString(p.Y.Bytes()))
}
1050170
func (p *Point) Set(x, y float32) *Point {
	p.X = x
	p.Y = y
	return p
}
794657
func NewPoint(lat float64, lng float64) *Point {
	return &Point{lat: lat, lng: lng}
}
234554
func (rect *Rect) ContainsPoint(p *T) bool {
	return p[0] >= rect.Min[0] && p[0] <= rect.Max[0] &&
		p[1] >= rect.Min[1] && p[1] <= rect.Max[1]
}
1364450
func Project(x, a, b Point) Point {
	aXb := a.PointCross(b)
	// Find the closest point to X along the great circle through AB.
	p := x.Sub(aXb.Mul(x.Dot(aXb.Vector) / aXb.Vector.Norm2()))

	// If this point is on the edge AB, then it's the closest point.
	if Sign(aXb, a, Point{p}) && Sign(Point{p}, b, aXb) {
		return Point{p.Normalize()}
	}

	// Otherwise, the closest point is either A or B.
	if x.Sub(a.Vector).Norm2() <= x.Sub(b.Vector).Norm2() {
		return a
	}
	return b
}
793213
func (f *Fpdf) point(x, y float64) {
	f.outf("%.2f %.2f m", x*f.k, (f.h-y)*f.k)
}
1344952
func (p *Point) ProjectOnto(p2 Point) Point {
	dot := p.X*p2.X + p.Y*p2.Y
	denom := p2.X*p2.X + p2.Y*p2.Y
	if FloatEqual(denom, 0) {
		return Point{}
	}
	return Point{
		dot / denom * p2.X,
		dot / denom * p2.Y,
	}
}
814881
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
}
671663
func MultiPoint(mp orb.MultiPoint, proj orb.Projection) orb.MultiPoint {
	for i := range mp {
		mp[i] = proj(mp[i])
	}

	return mp
}
720189
func (p *Polygon) Add(point *Point) {
	p.points = append(p.points, point)
}
166759
func (p Point) Equal(point Point) bool {
	return p[0] == point[0] && p[1] == point[1]
}
1114307
func (p *PlateCarreeProjection) Project(pt Point) r2.Point {
	return p.FromLatLng(LatLngFromPoint(pt))
}
1155906
func NormalizePoint(x []float64) {

	var sum float64
	for i := range x {
		sum += x[i] * x[i]
	}

	mag := math.Sqrt(sum)

	for i := range x {
		if math.IsInf(x[i]/mag, 0) || math.IsNaN(x[i]/mag) {
			// fallback to zero when dividing by 0
			x[i] = 0
			continue
		}

		x[i] /= mag
	}
}
249971
func (r Rect) Hi() Point {
	return Point{r.X.Hi, r.Y.Hi}
}