Added Add2D methods for PointF{,32}.

- Add2D adds x, y values instead of a point (Add).
This commit is contained in:
Sander Schobers 2019-12-24 10:48:49 +01:00
parent 3eeedf121e
commit f2705fcdf8
2 changed files with 10 additions and 0 deletions

View File

@ -22,6 +22,11 @@ func (p PointF) Add(q PointF) PointF {
return PointF{p.X + q.X, p.Y + q.Y}
}
// Add2D adds x and y to X and Y of point p and returns the sum.
func (p PointF) Add2D(x, y float64) PointF {
return PtF(p.X+x, p.Y+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))

View File

@ -22,6 +22,11 @@ func (p PointF32) Add(q PointF32) PointF32 {
return PointF32{p.X + q.X, p.Y + q.Y}
}
// Add2D adds x and y to X and Y of point p and returns the sum.
func (p PointF32) Add2D(x, y float32) PointF32 {
return PtF32(p.X+x, p.Y+y)
}
// AngleTo calculates the angle [0..2*Pi) from point p to point q.
func (p PointF32) AngleTo(q PointF32) float32 {
a := float32(math.Atan(float64((p.Y - q.Y) / (p.X - q.X))))