From 5e456a1326fe0b68b0c382a81a19208ccb34251b Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Sat, 25 Jun 2022 23:24:59 +0200 Subject: [PATCH] Updates some names and comments for SimpleVectorOperation --- .../stargate/SimpleVectorOperation.java | 39 +++++++------------ .../net/knarcraft/stargate/portal/Portal.java | 2 +- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/main/java/net/knarcraft/stargate/SimpleVectorOperation.java b/src/main/java/net/knarcraft/stargate/SimpleVectorOperation.java index 31d207c..09738b6 100644 --- a/src/main/java/net/knarcraft/stargate/SimpleVectorOperation.java +++ b/src/main/java/net/knarcraft/stargate/SimpleVectorOperation.java @@ -4,15 +4,17 @@ import org.bukkit.Axis; import org.bukkit.block.BlockFace; import org.bukkit.util.BlockVector; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; /** - * A simpler version of the vector operation class, but with the same functionality + * A class for performing rotational operations on vectors * * @author Kristian Knarvik */ +@SuppressWarnings("unused") public class SimpleVectorOperation { private static final Map rotationAngles = new HashMap<>(); @@ -28,10 +30,6 @@ public class SimpleVectorOperation { /** * Instantiates a vector operation to rotate vectors in the direction of a sign face * - *

Gate structures have their relative location represented by a vector where x = outwards, y = down and - * z = right. The vector operation rotates the given vectors so that "outwards" is going the same direction as the - * given sign face.

- * * @param signFace

The sign face of a gate's sign

*/ public SimpleVectorOperation(BlockFace signFace) { @@ -58,7 +56,7 @@ public class SimpleVectorOperation { * *

Said another way, get the axis going directly towards or away from a stargate's entrance.

* - * @return

The normal axis orthogonal to the iris plane

+ * @return

The normal axis orthogonal to the opening plane

*/ public Axis getNormalAxis() { return normalAxis; @@ -74,15 +72,12 @@ public class SimpleVectorOperation { } /** - * Performs this vector operation on the given vector - * - *

Inverse operation of doInverse; A vector operation that rotates around the origin, and flips the z-axis. - * Does not permute input vector

+ * Performs an operation from the real space to the vector space * * @param vector

The vector to perform the operation on

* @return vector

A new vector with the operation applied

*/ - public Vector performOperation(Vector vector) { + public Vector performToAbstractSpaceOperation(@NotNull Vector vector) { Vector clone = vector.clone(); clone.rotateAroundAxis(rotationAxes.get(facing), rotationAngles.get(facing)); if (flipZAxis) { @@ -92,15 +87,12 @@ public class SimpleVectorOperation { } /** - * Performs the reverse of this vector operation on the given vector - * - *

Inverse operation of doOperation; A vector operation that rotates around - * the origin and flips the z-axis. Does not permute input vector

+ * Performs an operation from the vector space to the real space * * @param vector

The vector to perform the inverse operation on

- * @return vector

A new vector with the inverse operation applied

+ * @return vector

A new vector with the operation applied

*/ - public Vector performInverseOperation(Vector vector) { + public Vector performToRealSpaceOperation(@NotNull Vector vector) { Vector clone = vector.clone(); if (flipZAxis) { clone.setZ(-clone.getZ()); @@ -109,16 +101,13 @@ public class SimpleVectorOperation { } /** - * Performs the reverse of this vector operation on the given vector - * - *

Inverse operation of doOperation; A vector operation that rotates around - * the origin and flips the z-axis. Does not permute input vector

+ * Performs an operation from the vector space to the real space * * @param vector

The vector to perform the inverse operation on

- * @return vector

A new vector with the inverse operation applied

+ * @return vector

A new vector with the operation applied

*/ - public BlockVector performInverseOperation(BlockVector vector) { - return performInverseOperation((Vector) vector).toBlockVector(); + public BlockVector performToRealSpaceOperation(@NotNull BlockVector vector) { + return performToRealSpaceOperation((Vector) vector).toBlockVector(); } /** @@ -188,4 +177,4 @@ public class SimpleVectorOperation { normalAxes.put(BlockFace.DOWN, Axis.Y); } -} +} \ No newline at end of file diff --git a/src/main/java/net/knarcraft/stargate/portal/Portal.java b/src/main/java/net/knarcraft/stargate/portal/Portal.java index 6d1f159..9af1838 100644 --- a/src/main/java/net/knarcraft/stargate/portal/Portal.java +++ b/src/main/java/net/knarcraft/stargate/portal/Portal.java @@ -298,7 +298,7 @@ public class Portal { * @return

The block at the given relative position

*/ public BlockLocation getBlockAt(RelativeBlockVector vector) { - return (BlockLocation) getTopLeft().clone().add(vectorOperation.performOperation(vector.toVector())); + return (BlockLocation) getTopLeft().clone().add(vectorOperation.performToRealSpaceOperation(vector.toVector())); } /**