Class Vec2

All Implemented Interfaces:
Serializable

public class Vec2 extends Vec<Vec2> implements Serializable
Represents a vector with an x- and a y-component.
See Also:
Serialized Form
  • Field Details

    • x

      public float x
    • y

      public float y
  • Constructor Details

    • Vec2

      public Vec2()
      Create a vector initialized to [0, 0].
    • Vec2

      public Vec2(Vec2 vec)
      Creates a vector with the given values.
    • Vec2

      public Vec2(float x, float y)
      Creates a vector with the given values.
  • Method Details

    • set

      public Vec2 set(Vec2 vec)
      Sets the vector to the given values.
      Returns:
      this
    • set

      public Vec2 set(float x, float y)
      Sets the vector to the given values.
      Returns:
      this
    • getComponents

      protected float[] getComponents()
      Description copied from class: Vec
      Returns an array containing all components in the order they appear in the vector.
      Specified by:
      getComponents in class Vec<Vec2>
      Returns:
      array containing all vector components
    • setComponents

      protected void setComponents(float[] values)
      Description copied from class: Vec
      Sets the components of the vector.
      Specified by:
      setComponents in class Vec<Vec2>
      Parameters:
      values - an array containing the values for all components.
    • getNewVector

      protected Vec2 getNewVector()
      Description copied from class: Vec
      Creates a new vector (values don't matter) of this type.
      Specified by:
      getNewVector in class Vec<Vec2>
      Returns:
      new vector of this type