Added point (PointF) subtraction.
This commit is contained in:
parent
20f0bf7b1f
commit
bdfa821989
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user