func (w XY) Midpoint(o XY) XY {
	return w.Add(o).Scale(0.5)
}
Midpoint returns the midpoint of this and another XY.
package geom
import (
	"fmt"
	"math"
	"github.com/peterstace/simplefeatures/rtree"
)
type XY struct {
	X, Y float64
}
func (w XY) validate() error {
	if math.IsNaN(w.X) || math.IsInf(w.X, 0) {
		return fmt.Errorf("invalid X value: %v", w.X)
	}
	if math.IsNaN(w.Y) || math.IsInf(w.Y, 0) {
		return fmt.Errorf("invalid Y value: %v", w.Y)
	}
	return nil
}
func (w XY) AsPoint(opts ...ConstructorOption) (Point, error) {
	coords := Coordinates{XY: w, Type: DimXY}
	return NewPoint(coords, opts...)
}
func (w XY) asUncheckedPoint() Point {
	coords := Coordinates{XY: w, Type: DimXY}
	return newUncheckedPoint(coords)
}
func (w XY) uncheckedEnvelope() Envelope {
	return newUncheckedEnvelope(w, w)
}
func (w XY) Sub(o XY) XY {
	return XY{
		w.X - o.X,
		w.Y - o.Y,
	}
}
func (w XY) Add(o XY) XY {
	return XY{
		w.X + o.X,
		w.Y + o.Y,
	}
}
func (w XY) Scale(s float64) XY {
	return XY{
		w.X * s,
		w.Y * s,
	}
}
func (w XY) Cross(o XY) float64 {
	return (w.X * o.Y) - (w.Y * o.X)
}