package gg // The type represents mathematical equation of line and line itself. type Line struct { K, C Float } // Returns the line itself. Made to implement the Liner interface. func (l Line) Line() Line { return l } func (l Line) ContainsPoint(p Point) bool { buf := Line{0, p.Y} pc, ok := l.crossesLine(buf) if !ok { return false } return pc == p } func (l1 Line) crossesLine(l2 Line) (Point, bool) { if LinersParallel(l1, l2) { return Point{}, false } x := (l1.C - l2.C) / (l2.K - l1.K) y := l1.K*x + l1.C return Point{x, y}, true }