Rotates the vector around the x 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)
| 441 | * @return the same vector |
| 442 | */ |
| 443 | @NotNull |
| 444 | public Vector rotateAroundX(double angle) { |
| 445 | double angleCos = Math.cos(angle); |
| 446 | double angleSin = Math.sin(angle); |
| 447 | |
| 448 | double y = angleCos * getY() - angleSin * getZ(); |
| 449 | double z = angleSin * getY() + angleCos * getZ(); |
| 450 | return setY(y).setZ(z); |
| 451 | } |
| 452 | |
| 453 | /** |
| 454 | * Rotates the vector around the y axis. |