diff --git a/pointf.go b/pointf.go index 0a397a7..d83180b 100644 --- a/pointf.go +++ b/pointf.go @@ -28,11 +28,16 @@ func (p PointF) To32() PointF32 { return PointF32{float32(p.X), float32(p.Y)} } -// Add adds q as a vector to p +// Add adds q as a vector to p. func (p PointF) Add(q PointF) PointF { return PointF{p.X + q.X, p.Y + q.Y} } +// Sub subtracts q as a vector from p. +func (p PointF) Sub(q PointF) PointF { + return PointF{p.X - q.X, p.Y - q.Y} +} + // AngleTo calculates the angle [0..2*Pi) from point p to point q. func (p PointF) AngleTo(q PointF) float64 { a := math.Atan((p.Y - q.Y) / (p.X - q.X))