Rotates counterclockwise in radians. */
| 244 | } |
| 245 | /** Rotates counterclockwise in radians. */ |
| 246 | Vec rotate(float angle) { |
| 247 | float sin = std::sin(angle); |
| 248 | float cos = std::cos(angle); |
| 249 | return Vec(x * cos - y * sin, x * sin + y * cos); |
| 250 | } |
| 251 | /** Swaps the coordinates. |
| 252 | Equivalent to a reflection across the `y = x` line. |
| 253 | */ |