Module SypherEngine

Class Vector2

java.lang.Object
dev.aurumbyte.sypherengine.math.Vector2

public class Vector2 extends Object

The Vector2 class of SypherEngine, the base of all position

Since:
0.3.0
Author:
AurumByte
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) float
    The rotation of the vector
    float
    The xPos and yPos (in float)
    int
    The integer position of xPos and yPos, for people who are too lazy to cast to int XD
    float
    The xPos and yPos (in float)
    int
    The integer position of xPos and yPos, for people who are too lazy to cast to int XD
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an empty Vector of coords (0, 0)
    Vector2(float x, float y)
    Creates a Vector2 instance with x and y position
    Vector2(float x, float y, float rotation)
    Creates a Vector2 instance with a specified position and rotation
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(Vector2 vector2)
    Adds a Vector2 with another Vector2
    static double
    Calculates the distance between two vectors
    void
    divide(Vector2 vector2)
    Divides a Vector2 with another Vector2
    Gets the vector position
    float
    Gets the rotation of the Vector
    void
    multiply(Vector2 vector2)
    Multiplies a Vector2 with another Vector2
    void
    Normalizes the Vector
    void
    rotate(float rotation)
    Rotates the Vector
    void
    setPosition(float xPos, float yPos)
    Set the Vector's position
    void
    subtract(Vector2 vector2)
    Subtracts a Vector2 with another Vector2

    Methods inherited from class java.lang.Object

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

    • xPosi

      public int xPosi
      The integer position of xPos and yPos, for people who are too lazy to cast to int XD
    • yPosi

      public int yPosi
      The integer position of xPos and yPos, for people who are too lazy to cast to int XD
    • xPos

      public float xPos
      The xPos and yPos (in float)
    • yPos

      public float yPos
      The xPos and yPos (in float)
    • rotation

      float rotation
      The rotation of the vector
  • Constructor Details

    • Vector2

      public Vector2()

      Create an empty Vector of coords (0, 0)

      Since:
      0.3.0
    • Vector2

      public Vector2(float x, float y)

      Creates a Vector2 instance with x and y position

      Parameters:
      x - x position
      y - y position
      Since:
      0.3.0
    • Vector2

      public Vector2(float x, float y, float rotation)

      Creates a Vector2 instance with a specified position and rotation

      Parameters:
      x - x position
      y - y position
      rotation - rotation of the vector
      Since:
      0.3.0
  • Method Details

    • add

      public void add(Vector2 vector2)

      Adds a Vector2 with another Vector2

      Parameters:
      vector2 - The other Vector
      Since:
      0.3.0
    • subtract

      public void subtract(Vector2 vector2)

      Subtracts a Vector2 with another Vector2

      Parameters:
      vector2 - The other Vector
      Since:
      0.3.0
    • multiply

      public void multiply(Vector2 vector2)

      Multiplies a Vector2 with another Vector2

      Parameters:
      vector2 - The other Vector
      Since:
      0.3.0
    • divide

      public void divide(Vector2 vector2)

      Divides a Vector2 with another Vector2

      Parameters:
      vector2 - The other Vector
      Since:
      0.3.0
    • rotate

      public void rotate(float rotation)

      Rotates the Vector

      Parameters:
      rotation - The amount of rotation needed for the vector
      Since:
      0.3.0
    • setPosition

      public void setPosition(float xPos, float yPos)

      Set the Vector's position

      Parameters:
      xPos - The x position
      yPos - The y position
      Since:
      0.3.0
    • getPosition

      public Vector2 getPosition()

      Gets the vector position

      Since:
      0.3.0
    • getRotation

      public float getRotation()

      Gets the rotation of the Vector

      Since:
      0.3.0
    • normalize

      public void normalize()

      Normalizes the Vector

      Since:
      v0.3.0
    • distance

      public static double distance(Vector2 a, Vector2 b)

      Calculates the distance between two vectors

      Parameters:
      a - A Vector
      b - Another vector