A 2-dimensional vector. Typically represents a position, size, or direction in 2D space.
Degrees |
Return the angle of this vector in degrees, always between 0 and 360 |
Inverse |
Returns the inverse of this vector, which is useful for scaling vectors |
IsInfinity |
Returns true if x, y, or z are infinity |
IsNaN |
Returns true if x, y, or z are NaN |
IsNearZeroLength |
Returns true if the squared length is less than 1e-8 (which is really near zero) |
Item |
|
Length |
Returns the magnitude of the vector |
LengthSquared |
This is faster than Length, so is better to use in certain circumstances |
Normal |
Return the same vector but with a length of one |
Perpendicular |
Returns a vector that runs perpendicular to this one |
x |
X component of this vector. |
y |
Y component of this vector. |
Abs |
Returns a new vector with all values positive. -5 becomes 5, etc. |
AddClamped |
Try to add to this vector. If we're already over max then don't add.
If we're over max when we add, clamp in that direction so we're not. |
AlmostEqual |
Returns true if we're nearly equal to the passed vector. |
Angle |
Returns the distance between this vector and another in degrees. |
Approach |
Returns a new vector whos length is closer to given target length by given amount. |
Clamp |
Returns a vector each axis of which is clamped to between the 2 given vectors. Basically clamps a point to a square. |
ClampLength |
Returns a vector whose length is limited to given maximum |
ComponentMax |
Returns a vector that has the maximum values on each axis between this vector and given vector. |
ComponentMin |
Returns a vector that has the minimum values on each axis between this vector and given vector. |
IsNearlyZero |
Returns true if value on every axis is less than tolerance away from zero |
LerpTo |
Linearly interpolate from this vector to given vector. |
RotateAround |
Rotate this vector around given point by given angle in degrees and
return the result as a new vector. |
SnapToGrid |
Snap to grid along all 3 axes. |
SubtractDirection |
Given a vector like 1,1,1 and direction 1,0,0, will return 0,1,1.
This is useful for velocity collision type events, where you want to
cancel out velocity based on a normal.
For this to work properly, direction should be a normal, but you can scale
how much you want to subtract by scaling the direction. Ie, passing in a direction
with a length of 0.5 will remove half the direction. |
WithAcceleration |
Move to the target vector, by amount acceleration |
WithFriction |
|
WithX |
Return this vector with given X. |
WithY |
Return this vector with given Y. |
CubicBezier |
Calculates position of a point on a cubic bezier curve at given fraction. |
Direction |
Calculates the normalized direction vector from one point to another in 2D space. |
Distance |
Returns distance between the 2 given vectors. |
DistanceBetween |
Returns distance between the 2 given vectors. |
DistanceBetweenSquared |
Returns squared distance between the 2 given vectors. This is faster than <see cref="M:Vector2.DistanceBetween(Vector2,Vector2)">DistanceBetween</see>,
and can be used for things like comparing distances, as long as only squared values are used. |
DistanceSquared |
Returns squared distance between the 2 given vectors. This is faster than <see cref="M:Vector2.DistanceBetween(Vector2,Vector2)">DistanceBetween</see>,
and can be used for things like comparing distances, as long as only squared values are used. |
Dot |
Returns the scalar/dot product between the 2 given vectors. |
FromDegrees |
Returns a point on a circle at given rotation from X axis, counter clockwise. |
FromRadians |
Returns a point on a circle at given rotation from X axis, counter clockwise. |
GetAngle |
Returns the distance between two direction vectors in degrees. |
Lerp |
Linearly interpolate from point a to point b. |
Max |
Returns a vector that has the maximum values on each axis between the 2 given vectors. |
Min |
Returns a vector that has the minimum values on each axis between the 2 given vectors. |
Parse |
Given a string, try to convert this into a Vector2. Example formatting is "x,y", "[x,y]", "x y", etc. |
Reflect |
Returns a reflected vector based on incoming direction and plane normal. Like a ray reflecting off of a mirror. |
SmoothDamp |
Smoothly move towards the target vector |
Sort |
Sort these two vectors into min and max. This doesn't just swap the vectors, it sorts each component.
So that min will come out containing the minimum x and y values. |
SpringDamp |
Springly move towards the target vector |
TryParse |
|