struct Vector2

book_4_sparkGenerated
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 (by reference).
DistanceBetweenSquaredCalculates the squared distance between two vectors.
DistanceSquaredCalculates the squared distance between two vectors (by reference).
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.
MinReturns the component-wise minimum of two vectors.
MaxReturns the component-wise maximum of two vectors.
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 a specified X value.
WithYReturns a new vector with a specified Y value.
LerpToInterpolates the vector towards a target vector.
ClampClamps the vector within a specified range.
ComponentMinReturns the component-wise minimum with another vector.
ComponentMaxReturns the component-wise maximum with another vector.
AbsReturns a new vector with all values positive.
xX component of this Vector.
yY component of this Vector.
LengthReturns the magnitude of the vector.
LengthSquaredReturns the squared magnitude of the vector.
PerpendicularReturns a vector that runs perpendicular to this one.
IsNearZeroLengthReturns true if the squared length is near zero.
NormalReturns the normalized vector.
DegreesReturns the angle of this vector in degrees.