added geom and flag in main for deebug cli calls

This commit is contained in:
Doc
2025-08-21 11:31:00 +02:00
parent e695c39e5a
commit 7dd13e6256
2 changed files with 74 additions and 1 deletions

View File

@@ -1,3 +1,20 @@
package geom
//init
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 }