Class VectorTools

java.lang.Object
com.github.yellowstonegames.smooth.VectorTools

public class VectorTools extends Object
Utilities for handling floating-point positions, to be added to as needed.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    appendSerializedString(StringBuilder sb, com.badlogic.gdx.math.Vector2 vec)
    Appends the serialized representation of the given Vector2 to the given StringBuilder.
    static com.badlogic.gdx.math.Vector2
    randomUnit(com.badlogic.gdx.math.Vector2 receiving, com.github.tommyettinger.random.EnhancedRandom random)
    Generates one random int and uses it as an angle to fill receiving's x and y with a position on the unit circle.
    static com.badlogic.gdx.math.Vector2
    Deserializes a Vector2 from the given String using stringDeserialize(String, Vector2), allocating a new Vector2 that this returns.
    static String
    serializeString(com.badlogic.gdx.math.Vector2 vec)
    Serializes the given Vector2 and returns it as a new String.
    static com.badlogic.gdx.math.Vector2
    stringDeserialize(String data, com.badlogic.gdx.math.Vector2 receiving)
    Deserializes the given String to get the values this assigns to the Vector2 receiving.

    Methods inherited from class Object

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

    • VectorTools

      public VectorTools()
  • Method Details

    • randomUnit

      public static com.badlogic.gdx.math.Vector2 randomUnit(com.badlogic.gdx.math.Vector2 receiving, com.github.tommyettinger.random.EnhancedRandom random)
      Generates one random int and uses it as an angle to fill receiving's x and y with a position on the unit circle.
      Parameters:
      receiving - a Vector2 that will be completely modified
      random - any EnhancedRandom object
      Returns:
      receiving, after modification
    • appendSerializedString

      public static StringBuilder appendSerializedString(StringBuilder sb, com.badlogic.gdx.math.Vector2 vec)
      Appends the serialized representation of the given Vector2 to the given StringBuilder.
      Parameters:
      sb - a non-null StringBuilder
      vec - a non-null Vector2 to serialize
      Returns:
      sb, after modifications
    • serializeString

      public static String serializeString(com.badlogic.gdx.math.Vector2 vec)
      Serializes the given Vector2 and returns it as a new String.
      Parameters:
      vec - a non-null Vector2 to serialize
      Returns:
      the serialized String version of vec
    • stringDeserialize

      public static com.badlogic.gdx.math.Vector2 stringDeserialize(String data, com.badlogic.gdx.math.Vector2 receiving)
      Deserializes the given String to get the values this assigns to the Vector2 receiving.
      Parameters:
      data - a String containing a serialized Vector2
      receiving - a non-null Vector2 that will have its contents reassigned
      Returns:
      receiving, after modifications
    • recreateFromString

      public static com.badlogic.gdx.math.Vector2 recreateFromString(String data)
      Deserializes a Vector2 from the given String using stringDeserialize(String, Vector2), allocating a new Vector2 that this returns.
      Parameters:
      data - a String containing a serialized Vector2
      Returns:
      a new Vector2 using the values from data