package geom import "math" const EPS = 1e-6 type Vec struct { X, Y float64 } type Seg struct { A, B Vec } func V(x, y float64) Vec { return Vec{x, y} } func Sub(a, b Vec) Vec { return Vec{a.X - b.X, a.Y - b.Y} } func Dot(a, b Vec) float64 { return a.X*b.X + a.Y*b.Y } func Cross(a, b Vec) float64 { return a.X*b.Y - a.Y*b.X } func Len(a Vec) float64 { return math.Hypot(a.X, a.Y) } func NearlyZero(x float64) bool { return math.Abs(x) < EPS }