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)
| 469 | * @return the same vector |
| 470 | */ |
| 471 | @NotNull |
| 472 | public Vector rotateAroundZ(double angle) { |
| 473 | double angleCos = Math.cos(angle); |
| 474 | double angleSin = Math.sin(angle); |
| 475 | |
| 476 | double x = angleCos * getX() - angleSin * getY(); |
| 477 | double y = angleSin * getX() + angleCos * getY(); |
| 478 | return setX(x).setY(y); |
| 479 | } |
| 480 | |
| 481 | /** |
| 482 | * Rotates the vector around a given arbitrary axis in 3 dimensional space. |