struct Vector2

robot_2Generated
code_blocksInput

Description

A 2-dimensional vector. Typically represents a position or size in 2D space.

Members

Static Members

Member NameSummary
FromRadiansCreates a Vector2 from an angle in radians.
FromDegreesCreates a Vector2 from an angle in degrees.
DistanceBetweenCalculates the distance between two vectors.
DistanceCalculates the distance between two vectors.
DistanceBetweenSquaredCalculates the squared distance between two vectors.
DistanceSquaredCalculates the squared distance between two vectors.
DotCalculates the dot product of two vectors.
LerpLinearly interpolates between two vectors.
DirectionCalculates the direction from one vector to another.
ParseParses a string to create a Vector2.
TryParseTries to parse a string to create a Vector2.
OneReturns a 2D vector with every component set to 1.
ZeroReturns a 2D vector with every component set to 0.
UpReturns a 2D vector with Y set to 1, representing the upwards direction.
DownReturns a 2D vector with Y set to -1, representing the downwards direction.
LeftReturns a 2D vector with X set to 1, representing the left direction.
RightReturns a 2D vector with X set to -1, representing the right direction.
RandomSamples a random 2D position within a unit circle.

Instance Members

Member NameSummary
DistanceCalculates the distance to another vector.
DistanceSquaredCalculates the squared distance to another vector.
AlmostEqualChecks if two vectors are approximately equal within a delta.
SnapToGridSnaps the vector to a grid of a specified size.
WithXReturns a new vector with the X component set to a specified value.
WithYReturns a new vector with the Y component set to a specified value.
LerpToInterpolates the vector towards a target vector.
ClampClamps the vector within a specified range.
ComponentMinReturns a vector with the minimum components of this and another vector.
ComponentMaxReturns a vector with the maximum components of this and another vector.
AbsReturns a new vector with all values positive.
LengthReturns the magnitude of the vector.
LengthSquaredReturns the squared magnitude of the vector.
PerpendicularReturns a vector that is perpendicular to this one.
IsNearZeroLengthChecks if the vector's length is near zero.
NormalReturns a normalized version of the vector.
DegreesReturns the angle of the vector in degrees.
xX component of this Vector.
yY component of this Vector.