Gets a unit-vector pointing in the direction that this Location is facing. @return a vector pointing the direction of this location's #getPitch() pitch and #getYaw() yaw
()
| 291 | * #getPitch() pitch} and {@link #getYaw() yaw} |
| 292 | */ |
| 293 | @NotNull |
| 294 | public Vector getDirection() { |
| 295 | Vector vector = new Vector(); |
| 296 | |
| 297 | double rotX = this.getYaw(); |
| 298 | double rotY = this.getPitch(); |
| 299 | |
| 300 | vector.setY(-Math.sin(Math.toRadians(rotY))); |
| 301 | |
| 302 | double xz = Math.cos(Math.toRadians(rotY)); |
| 303 | |
| 304 | vector.setX(-xz * Math.sin(Math.toRadians(rotX))); |
| 305 | vector.setZ(xz * Math.cos(Math.toRadians(rotX))); |
| 306 | |
| 307 | return vector; |
| 308 | } |
| 309 | |
| 310 | /** |
| 311 | * Sets the {@link #getYaw() yaw} and {@link #getPitch() pitch} to point |