Class VectorTools
java.lang.Object
com.github.yellowstonegames.smooth.VectorTools
Utilities for handling floating-point positions, to be added to as needed.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringBuilderappendSerializedString(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.Vector2randomUnit(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.Vector2recreateFromString(String data) Deserializes a Vector2 from the given String usingstringDeserialize(String, Vector2), allocating a new Vector2 that this returns.static StringserializeString(com.badlogic.gdx.math.Vector2 vec) Serializes the given Vector2 and returns it as a new String.static com.badlogic.gdx.math.Vector2stringDeserialize(String data, com.badlogic.gdx.math.Vector2 receiving) Deserializes the given String to get the values this assigns to the Vector2receiving.
-
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 modifiedrandom- 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 StringBuildervec- a non-null Vector2 to serialize- Returns:
- sb, after modifications
-
serializeString
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 Vector2receiving.- Parameters:
data- a String containing a serialized Vector2receiving- a non-null Vector2 that will have its contents reassigned- Returns:
- receiving, after modifications
-
recreateFromString
Deserializes a Vector2 from the given String usingstringDeserialize(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
-