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)
| 463 | * @return the same vector |
| 464 | */ |
| 465 | @NotNull |
| 466 | public Vector rotateAroundY(double angle) { |
| 467 | double angleCos = Math.cos(angle); |
| 468 | double angleSin = Math.sin(angle); |
| 469 | |
| 470 | double x = angleCos * getX() + angleSin * getZ(); |
| 471 | double z = -angleSin * getX() + angleCos * getZ(); |
| 472 | return setX(x).setZ(z); |
| 473 | } |
| 474 | |
| 475 | /** |
| 476 | * Rotates the vector around the z axis |