(rect *sdl.FRect)
| 161 | } |
| 162 | |
| 163 | func (point Vector) DistanceToRect(rect *sdl.FRect) float32 { |
| 164 | closestX := math.Max(float64(rect.X), math.Min(float64(point.X), float64(rect.X+rect.W))) |
| 165 | closestY := math.Max(float64(rect.Y), math.Min(float64(point.Y), float64(rect.Y+rect.H))) |
| 166 | return point.Distance(Vector{float32(closestX), float32(closestY)}) |
| 167 | } |
| 168 | |
| 169 | func (point Vector) Length() float32 { |
| 170 | return point.Distance(Vector{0, 0}) |