Magnitude returns the length of the Point.
()
| 203 | |
| 204 | // Magnitude returns the length of the Point. |
| 205 | func (point Vector) Magnitude() float32 { |
| 206 | return float32(math.Sqrt(float64(point.X*point.X + point.Y*point.Y))) |
| 207 | } |
| 208 | |
| 209 | func (point Vector) Scale(scalar float32) Vector { |
| 210 | point.X *= scalar |