Rotates the vector around the z axis This piece of math is based on the standard rotation matrix for vectors in three dimensional space. This matrix can be found here: Rotation Matrix . @param angle the angle to rotate t
(double angle)
| 485 | * @return the same vector |
| 486 | */ |
| 487 | @NotNull |
| 488 | public Vector rotateAroundZ(double angle) { |
| 489 | double angleCos = Math.cos(angle); |
| 490 | double angleSin = Math.sin(angle); |
| 491 | |
| 492 | double x = angleCos * getX() - angleSin * getY(); |
| 493 | double y = angleSin * getX() + angleCos * getY(); |
| 494 | return setX(x).setY(y); |
| 495 | } |
| 496 | |
| 497 | /** |
| 498 | * Rotates the vector around a given arbitrary axis in 3 dimensional space. |