Updates some names and comments for SimpleVectorOperation
This commit is contained in:
parent
99ee5c6978
commit
5e456a1326
@ -4,15 +4,17 @@ import org.bukkit.Axis;
|
|||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.util.BlockVector;
|
import org.bukkit.util.BlockVector;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
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
|
* @author Kristian Knarvik
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class SimpleVectorOperation {
|
public class SimpleVectorOperation {
|
||||||
|
|
||||||
private static final Map<BlockFace, Double> rotationAngles = new HashMap<>();
|
private static final Map<BlockFace, Double> rotationAngles = new HashMap<>();
|
||||||
@ -28,10 +30,6 @@ public class SimpleVectorOperation {
|
|||||||
/**
|
/**
|
||||||
* Instantiates a vector operation to rotate vectors in the direction of a sign face
|
* Instantiates a vector operation to rotate vectors in the direction of a sign face
|
||||||
*
|
*
|
||||||
* <p>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.</p>
|
|
||||||
*
|
|
||||||
* @param signFace <p>The sign face of a gate's sign</p>
|
* @param signFace <p>The sign face of a gate's sign</p>
|
||||||
*/
|
*/
|
||||||
public SimpleVectorOperation(BlockFace signFace) {
|
public SimpleVectorOperation(BlockFace signFace) {
|
||||||
@ -58,7 +56,7 @@ public class SimpleVectorOperation {
|
|||||||
*
|
*
|
||||||
* <p>Said another way, get the axis going directly towards or away from a stargate's entrance.</p>
|
* <p>Said another way, get the axis going directly towards or away from a stargate's entrance.</p>
|
||||||
*
|
*
|
||||||
* @return <p>The normal axis orthogonal to the iris plane</p>
|
* @return <p>The normal axis orthogonal to the opening plane</p>
|
||||||
*/
|
*/
|
||||||
public Axis getNormalAxis() {
|
public Axis getNormalAxis() {
|
||||||
return normalAxis;
|
return normalAxis;
|
||||||
@ -74,15 +72,12 @@ public class SimpleVectorOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs this vector operation on the given vector
|
* Performs an operation from the real space to the vector space
|
||||||
*
|
|
||||||
* <p>Inverse operation of doInverse; A vector operation that rotates around the origin, and flips the z-axis.
|
|
||||||
* Does not permute input vector</p>
|
|
||||||
*
|
*
|
||||||
* @param vector <p>The vector to perform the operation on</p>
|
* @param vector <p>The vector to perform the operation on</p>
|
||||||
* @return vector <p>A new vector with the operation applied</p>
|
* @return vector <p>A new vector with the operation applied</p>
|
||||||
*/
|
*/
|
||||||
public Vector performOperation(Vector vector) {
|
public Vector performToAbstractSpaceOperation(@NotNull Vector vector) {
|
||||||
Vector clone = vector.clone();
|
Vector clone = vector.clone();
|
||||||
clone.rotateAroundAxis(rotationAxes.get(facing), rotationAngles.get(facing));
|
clone.rotateAroundAxis(rotationAxes.get(facing), rotationAngles.get(facing));
|
||||||
if (flipZAxis) {
|
if (flipZAxis) {
|
||||||
@ -92,15 +87,12 @@ public class SimpleVectorOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the reverse of this vector operation on the given vector
|
* Performs an operation from the vector space to the real space
|
||||||
*
|
|
||||||
* <p>Inverse operation of doOperation; A vector operation that rotates around
|
|
||||||
* the origin and flips the z-axis. Does not permute input vector</p>
|
|
||||||
*
|
*
|
||||||
* @param vector <p>The vector to perform the inverse operation on</p>
|
* @param vector <p>The vector to perform the inverse operation on</p>
|
||||||
* @return vector <p>A new vector with the inverse operation applied</p>
|
* @return vector <p>A new vector with the operation applied</p>
|
||||||
*/
|
*/
|
||||||
public Vector performInverseOperation(Vector vector) {
|
public Vector performToRealSpaceOperation(@NotNull Vector vector) {
|
||||||
Vector clone = vector.clone();
|
Vector clone = vector.clone();
|
||||||
if (flipZAxis) {
|
if (flipZAxis) {
|
||||||
clone.setZ(-clone.getZ());
|
clone.setZ(-clone.getZ());
|
||||||
@ -109,16 +101,13 @@ public class SimpleVectorOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the reverse of this vector operation on the given vector
|
* Performs an operation from the vector space to the real space
|
||||||
*
|
|
||||||
* <p>Inverse operation of doOperation; A vector operation that rotates around
|
|
||||||
* the origin and flips the z-axis. Does not permute input vector</p>
|
|
||||||
*
|
*
|
||||||
* @param vector <p>The vector to perform the inverse operation on</p>
|
* @param vector <p>The vector to perform the inverse operation on</p>
|
||||||
* @return vector <p>A new vector with the inverse operation applied</p>
|
* @return vector <p>A new vector with the operation applied</p>
|
||||||
*/
|
*/
|
||||||
public BlockVector performInverseOperation(BlockVector vector) {
|
public BlockVector performToRealSpaceOperation(@NotNull BlockVector vector) {
|
||||||
return performInverseOperation((Vector) vector).toBlockVector();
|
return performToRealSpaceOperation((Vector) vector).toBlockVector();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -298,7 +298,7 @@ public class Portal {
|
|||||||
* @return <p>The block at the given relative position</p>
|
* @return <p>The block at the given relative position</p>
|
||||||
*/
|
*/
|
||||||
public BlockLocation getBlockAt(RelativeBlockVector vector) {
|
public BlockLocation getBlockAt(RelativeBlockVector vector) {
|
||||||
return (BlockLocation) getTopLeft().clone().add(vectorOperation.performOperation(vector.toVector()));
|
return (BlockLocation) getTopLeft().clone().add(vectorOperation.performToRealSpaceOperation(vector.toVector()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user