Rotates the vector around the y 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
(double angle)
| 447 | * @return the same vector |
| 448 | */ |
| 449 | @NotNull |
| 450 | public Vector rotateAroundY(double angle) { |
| 451 | double angleCos = Math.cos(angle); |
| 452 | double angleSin = Math.sin(angle); |
| 453 | |
| 454 | double x = angleCos * getX() + angleSin * getZ(); |
| 455 | double z = -angleSin * getX() + angleCos * getZ(); |
| 456 | return setX(x).setZ(z); |
| 457 | } |
| 458 | |
| 459 | /** |
| 460 | * Rotates the vector around the z axis |