Convert this vector into a unit vector. Returns the length.
()
| 115 | |
| 116 | /// Convert this vector into a unit vector. Returns the length. |
| 117 | func (v *B2Vec2) Normalize() float64 { |
| 118 | |
| 119 | length := v.Length() |
| 120 | |
| 121 | if length < B2_epsilon { |
| 122 | return 0.0 |
| 123 | } |
| 124 | |
| 125 | invLength := 1.0 / length |
| 126 | v.X *= invLength |
| 127 | v.Y *= invLength |
| 128 | |
| 129 | return length |
| 130 | } |
| 131 | |
| 132 | /// Does this vector contain finite coordinates? |
| 133 | func (v B2Vec2) IsValid() bool { |
no test coverage detected