Class VectorUtils

java.lang.Object
org.sgrewritten.stargate.util.VectorUtils

public class VectorUtils extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    calculateAngleDifference(org.bukkit.block.BlockFace originFace, org.bukkit.block.BlockFace destinationFace)
    Calculates the relative angle difference between two block faces
    static double
    directionalAngleOperator(org.bukkit.util.Vector vector1, org.bukkit.util.Vector vector2)
    Gets the angle between two vectors
    static org.bukkit.util.BlockVector[]
    Get all relative blockvectors that represent a position that represent a block adjacent to (0 0 0)
    static org.bukkit.util.Vector
    getFormatSpaceCoordinate(org.bukkit.Location topLeft, VectorOperation vectorOperation, org.bukkit.Location location)
    Convert between two different coordinate systems.
    static org.bukkit.Location
    getLocation(org.bukkit.Location topLeft, VectorOperation vectorOperation, org.bukkit.util.Vector vector)
    Convert between two different coordinate systems.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getAdjacentRelativePositions

      public static org.bukkit.util.BlockVector[] getAdjacentRelativePositions()
      Get all relative blockvectors that represent a position that represent a block adjacent to (0 0 0)
      Returns:

      A list of all adjacent blocks to the (0 0 0) relative location

    • calculateAngleDifference

      public static double calculateAngleDifference(org.bukkit.block.BlockFace originFace, org.bukkit.block.BlockFace destinationFace)
      Calculates the relative angle difference between two block faces
      Parameters:
      originFace -

      The block face the origin portal is pointing towards

      destinationFace -

      The block face the destination portal is pointing towards

      Returns:

      The angle difference between the two block faces

    • directionalAngleOperator

      public static double directionalAngleOperator(org.bukkit.util.Vector vector1, org.bukkit.util.Vector vector2)
      Gets the angle between two vectors

      The Vector.angle(Vector) function is not directional, meaning if you exchange position with vectors, there will be no difference in angle. The behaviour that is needed in some portal methods is for the angle to change sign if the vectors change places.

      NOTE: ONLY ACCOUNTS FOR Y AXIS ROTATIONS

      Parameters:
      vector1 -

      The first vector

      vector2 -

      The second vector

      Returns:

      The angle between the two vectors

    • getLocation

      public static org.bukkit.Location getLocation(org.bukkit.Location topLeft, VectorOperation vectorOperation, org.bukkit.util.Vector vector)
      Convert between two different coordinate systems. In this case from format space to minecraft space
      Parameters:
      topLeft -

      Origo of system in format space

      vectorOperation -

      Rotations and z axis flips to convert between coordinate systems

      vector -

      The vector to convert

      Returns:

      A location in minecraft space

    • getFormatSpaceCoordinate

      public static org.bukkit.util.Vector getFormatSpaceCoordinate(org.bukkit.Location topLeft, VectorOperation vectorOperation, org.bukkit.Location location)
      Convert between two different coordinate systems. In this case from minecraft space to format space
      Parameters:
      topLeft -

      The origo of format space

      vectorOperation -

      Rotations and z axis flips to convert between coordinate systems

      location -

      A location to convert from

      Returns:

      A vector in format space