2016-02-21 05:11:34 +01:00
|
|
|
package gg
|
|
|
|
|
2016-02-23 03:00:39 +01:00
|
|
|
import (
|
|
|
|
"math"
|
|
|
|
|
|
|
|
"golang.org/x/image/math/fixed"
|
|
|
|
)
|
2016-02-21 05:11:34 +01:00
|
|
|
|
|
|
|
type Point struct {
|
|
|
|
X, Y float64
|
|
|
|
}
|
|
|
|
|
2016-02-23 03:00:39 +01:00
|
|
|
func (a Point) Fixed() fixed.Point26_6 {
|
2016-02-23 04:33:22 +01:00
|
|
|
return fixp(a.X, a.Y)
|
2016-02-23 03:00:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a Point) Distance(b Point) float64 {
|
|
|
|
return math.Hypot(a.X-b.X, a.Y-b.Y)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a Point) Interpolate(b Point, t float64) Point {
|
|
|
|
x := a.X + (b.X-a.X)*t
|
|
|
|
y := a.Y + (b.Y-a.Y)*t
|
|
|
|
return Point{x, y}
|
2016-02-21 05:11:34 +01:00
|
|
|
}
|