moved geom.go into this repo
This commit is contained in:
parent
abb7daf18d
commit
1610816e8a
@ -69,3 +69,14 @@ func (v Vector2d) Normalize() Vector2d {
|
|||||||
m := v.Mag()
|
m := v.Mag()
|
||||||
return Vector2d{v.X / m, v.Y / m}
|
return Vector2d{v.X / m, v.Y / m}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Move(d1, d2 Point2d, velocity float64, timeDelta float64) Point2d {
|
||||||
|
v := d2.Sub(d1)
|
||||||
|
v_norm := v.Normalize()
|
||||||
|
v_scaled := v_norm.Scale(velocity * timeDelta)
|
||||||
|
return d1.Add(v_scaled)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Distance(p1, p2 Point2d) float64 {
|
||||||
|
return p1.Sub(p2).Mag()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user