MCPcopy Create free account
hub / github.com/Teneted/Tenet / rotateAroundNonUnitAxis

Method rotateAroundNonUnitAxis

src/main/java/org/bukkit/util/Vector.java:529–551  ·  view source on GitHub ↗

Rotates the vector around a given arbitrary axis in 3 dimensional space. Rotation will follow the general Right-Hand-Rule, which means rotation will be counterclockwise when the axis is pointing towards the observer. Note that the vector length will change accordingly to the axis vector len

(@NotNull Vector axis, double angle)

Source from the content-addressed store, hash-verified

527 * null
528 */
529 @NotNull
530 public Vector rotateAroundNonUnitAxis(@NotNull Vector axis, double angle) throws IllegalArgumentException {
531 Preconditions.checkArgument(axis != null, "The provided axis vector was null");
532
533 double x = getX(), y = getY(), z = getZ();
534 double x2 = axis.getX(), y2 = axis.getY(), z2 = axis.getZ();
535
536 double cosTheta = Math.cos(angle);
537 double sinTheta = Math.sin(angle);
538 double dotProduct = this.dot(axis);
539
540 double xPrime = x2 * dotProduct * (1d - cosTheta)
541 + x * cosTheta
542 + (-z2 * y + y2 * z) * sinTheta;
543 double yPrime = y2 * dotProduct * (1d - cosTheta)
544 + y * cosTheta
545 + (z2 * x - x2 * z) * sinTheta;
546 double zPrime = z2 * dotProduct * (1d - cosTheta)
547 + z * cosTheta
548 + (-y2 * x + x2 * y) * sinTheta;
549
550 return setX(xPrime).setY(yPrime).setZ(zPrime);
551 }
552
553 /**
554 * Gets the X component.

Callers 1

rotateAroundAxisMethod · 0.95

Calls 10

getXMethod · 0.95
getYMethod · 0.95
getZMethod · 0.95
dotMethod · 0.95
setXMethod · 0.95
getXMethod · 0.65
getYMethod · 0.65
getZMethod · 0.65
setZMethod · 0.45
setYMethod · 0.45

Tested by

no test coverage detected