Vector2 Struct Reference

vector of 2 floats More...

List of all members.

Public Member Functions

 Vector2 (float x, float y)
 constructor taking two floats
 Vector2 (float f)
 constructor taking one float
float Length ()
 return the length of this vector
float LengthSquared ()
 return the length squared of this vector
float Distance (Vector2 v)
 get the distance between this and another vector
float Distance (ref Vector2 v)
 get the distance between this and another vector
float DistanceSquared (Vector2 v)
 get the distance squared between this and another vector
float DistanceSquared (ref Vector2 v)
 get the distance squared between this and another vector
float Dot (Vector2 v)
 dot product of this and v
float Dot (ref Vector2 v)
 dot product of this and v
float Determinant (Vector2 v)
 return the determinant of the 2x2 matrix formed by this and v
float Determinant (ref Vector2 v)
 return the determinant of the 2x2 matrix formed by this and v
Vector2 Normalize ()
 return this vector normalized
void Normalize (out Vector2 result)
 return this vector normalized
Vector2 Abs ()
 element wise absolute value
void Abs (out Vector2 result)
 element wise absolute value
Vector2 Min (Vector2 v)
 element wise min
void Min (ref Vector2 v, out Vector2 result)
 element wise min
Vector2 Min (float f)
 element wise min
void Min (float f, out Vector2 result)
 element wise min
Vector2 Max (Vector2 v)
 element wise max
void Max (ref Vector2 v, out Vector2 result)
 element wise max
Vector2 Max (float f)
 element wise max
void Max (float f, out Vector2 result)
 element wise max
Vector2 Clamp (Vector2 min, Vector2 max)
 element wise clamp
void Clamp (ref Vector2 min, ref Vector2 max, out Vector2 result)
 element wise clamp
Vector2 Clamp (float min, float max)
 element wise clamp
void Clamp (float min, float max, out Vector2 result)
 element wise clamp
Vector2 Repeat (Vector2 min, Vector2 max)
 element wise repeat
void Repeat (ref Vector2 min, ref Vector2 max, out Vector2 result)
 element wise repeat
Vector2 Repeat (float min, float max)
 element wise repeat
void Repeat (float min, float max, out Vector2 result)
 element wise repeat
Vector2 Lerp (Vector2 v, float f)
 lerp between this and the other vector
void Lerp (ref Vector2 v, float f, out Vector2 result)
 lerp between this and the other vector
Vector2 Slerp (Vector2 v, float f)
 slerp between this and the other vector
void Slerp (ref Vector2 v, float f, out Vector2 result)
 slerp between this and the other vector
Vector2 MoveTo (Vector2 v, float length)
 move to target vector by specified length
void MoveTo (ref Vector2 v, float length, out Vector2 result)
 move to target vector by specified angle
Vector2 TurnTo (Vector2 v, float angle)
 turn to target vector by specified angle
void TurnTo (ref Vector2 v, float angle, out Vector2 result)
 turn to target vector by specified angle
float Angle (Vector2 v)
 return the angle between this and v
float Angle (ref Vector2 v)
 return the angle between this and v
Vector2 Rotate (float angle)
 return this vector rotated by angle
void Rotate (float angle, out Vector2 result)
 return this vector rotated by angle
Vector2 Rotate (Vector2 rotation)
 return this vector rotated by angle
void Rotate (ref Vector2 rotation, out Vector2 result)
 return this vector rotated by angle
Vector2 Reflect (Vector2 normal)
 return this vector reflected about normal
void Reflect (ref Vector2 normal, out Vector2 result)
 return this vector reflected about normal
Vector2 Perpendicular ()
 return a vector perpendicular to this
void Perpendicular (out Vector2 result)
 return this rotated by +pi/2
Vector2 ProjectOnLine (Vector2 point, Vector2 direction)
 project this onto the line (point,direction)
void ProjectOnLine (ref Vector2 point, ref Vector2 direction, out Vector2 result)
 project this onto the line (point,direction)
Vector2 Add (Vector2 v)
 return this + v
void Add (ref Vector2 v, out Vector2 result)
 result = this + v
Vector2 Subtract (Vector2 v)
 return this - v
void Subtract (ref Vector2 v, out Vector2 result)
 result = this - v
Vector2 Multiply (Vector2 v)
 return this * v
void Multiply (ref Vector2 v, out Vector2 result)
 result = this * v
Vector2 Multiply (float f)
 return this * f
void Multiply (float f, out Vector2 result)
 result = this * f
Vector2 Divide (Vector2 v)
 return this / v
void Divide (ref Vector2 v, out Vector2 result)
 result = this / v
Vector2 Divide (float f)
 return this / f
void Divide (float f, out Vector2 result)
 result = this / f
Vector2 Negate ()
 return -this
void Negate (out Vector2 result)
 result = -this
bool IsUnit (float epsilon)
 unit vector test
bool IsZero ()
 test if all elements of this are zero
bool IsOne ()
 test if all elements of this are one
bool IsInfinity ()
 test if any elements of this are Infinity
bool IsNaN ()
 test if any of the elements of this are NaN
bool Equals (Vector2 v, float epsilon)
 equality test with an epsilon
bool Equals (Vector2 v)
 equality test
override bool Equals (Object o)
 equality test
override string ToString ()
 convert vector to string
override int GetHashCode ()
 gets the hash code for this vector

Static Public Member Functions

static Vector2 Rotation (float angle)
 return a new vector that breaks a rotation angle into its x and y components
static void Rotation (float angle, out Vector2 result)
 return a new vector that breaks a rotation angle into its x and y components
static float Length (Vector2 v)
 static function equivalent to Length()
static float Length (ref Vector2 v)
 static function equivalent to Length()
static float LengthSquared (Vector2 v)
 static function equivalent to LengthSquared()
static float LengthSquared (ref Vector2 v)
 static function equivalent to LengthSquared()
static float Distance (Vector2 v1, Vector2 v2)
 static function equivalent to Distance(Vector2)
static float Distance (ref Vector2 v1, ref Vector2 v2)
 static function equivalent to Distance(ref Vector2)
static float DistanceSquared (Vector2 v1, Vector2 v2)
 static function equivalent to DistanceSquared(Vector2)
static float DistanceSquared (ref Vector2 v1, ref Vector2 v2)
 static function equivalent to DistanceSquared(ref Vector2)
static float Dot (Vector2 v1, Vector2 v2)
 static function equivalent to Dot(Vector2)
static float Dot (ref Vector2 v1, ref Vector2 v2)
 static function equivalent to Dot(ref Vector2)
static float Determinant (Vector2 v1, Vector2 v2)
 static function equivalent to Determinant(Vector2 v)
static float Determinant (ref Vector2 v1, ref Vector2 v2)
 static function equivalent to Determinant(ref Vector2 v)
static Vector2 Normalize (Vector2 v)
 static function equivalent to Normalize()
static void Normalize (ref Vector2 v, out Vector2 result)
 static function equivalent to Normalize(out Vector2)
static Vector2 Abs (Vector2 v)
 static function equivalent to Abs()
static void Abs (ref Vector2 v, out Vector2 result)
 static function equivalent to Abs(out Vector2)
static Vector2 Min (Vector2 v1, Vector2 v2)
 static function equivalent to Min(Vector2)
static void Min (ref Vector2 v1, ref Vector2 v2, out Vector2 result)
 static function equivalent to Min(ref Vector2, out Vector2)
static Vector2 Min (Vector2 v, float f)
 static function equivalent to Min(float)
static void Min (ref Vector2 v, float f, out Vector2 result)
 static function equivalent to Min(float, out Vector2)
static Vector2 Max (Vector2 v1, Vector2 v2)
 static function equivalent to Max(Vector2)
static void Max (ref Vector2 v1, ref Vector2 v2, out Vector2 result)
 static function equivalent to Max(ref Vector2, out Vector2)
static Vector2 Max (Vector2 v, float f)
 static function equivalent to Max(float)
static void Max (ref Vector2 v, float f, out Vector2 result)
 static function equivalent to Max(float, out Vector2)
static Vector2 Clamp (Vector2 v, Vector2 min, Vector2 max)
 static function equivalent to Clamp(Vector2, Vector2)
static void Clamp (ref Vector2 v, ref Vector2 min, ref Vector2 max, out Vector2 result)
 static function equivalent to Clamp(ref Vector2, ref Vector2, out Vector2)
static Vector2 Clamp (Vector2 v, float min, float max)
 static function equivalent to Clamp(float, float)
static void Clamp (ref Vector2 v, float min, float max, out Vector2 result)
 static function equivalent to Clamp(float, float, out Vector2)
static Vector2 Repeat (Vector2 v, Vector2 min, Vector2 max)
 static function equivalent to Repeat(Vector2, Vector2)
static void Repeat (ref Vector2 v, ref Vector2 min, ref Vector2 max, out Vector2 result)
 static function equivalent to Repeat(ref Vector2, ref Vector2, out Vector2)
static Vector2 Repeat (Vector2 v, float min, float max)
 static function equivalent to Repeat(float, float)
static void Repeat (ref Vector2 v, float min, float max, out Vector2 result)
 static function equivalent to Repeat(float, float, out Vector2)
static Vector2 Lerp (Vector2 v1, Vector2 v2, float f)
 static function equivalent to Lerp(Vector2, float)
static void Lerp (ref Vector2 v1, ref Vector2 v2, float f, out Vector2 result)
 static function equivalent to Lerp(ref Vector2, float, out Vector2)
static Vector2 Slerp (Vector2 v1, Vector2 v2, float f)
 static function equivalent to Slerp(Vector2, float)
static void Slerp (ref Vector2 v1, ref Vector2 v2, float f, out Vector2 result)
 static function equivalent to Slerp(ref Vector2, float, out Vector2)
static Vector2 MoveTo (Vector2 v1, Vector2 v2, float length)
 static function equivalent to MoveTo(Vector2, float)
static void MoveTo (ref Vector2 v1, ref Vector2 v2, float length, out Vector2 result)
 static function equivalent to MoveTo(ref Vector2, float, out Vector2)
static Vector2 TurnTo (Vector2 v1, Vector2 v2, float angle)
 static function equivalent to TurnTo(Vector2, float)
static void TurnTo (ref Vector2 v1, ref Vector2 v2, float angle, out Vector2 result)
 static function equivalent to TurnTo(ref Vector2, float, out Vector2)
static float Angle (Vector2 v1, Vector2 v2)
 static function equivalent to Angle(Vector2)
static float Angle (ref Vector2 v1, ref Vector2 v2)
 static function equivalent to Angle(ref Vector2)
static Vector2 Rotate (Vector2 v, float angle)
 static function equivalent to Rotate(float)
static void Rotate (ref Vector2 v, float angle, out Vector2 result)
 static function equivalent to Rotate(float, out Vector2)
static Vector2 Rotate (Vector2 v, Vector2 rotation)
 static function equivalent to Rotate(Vector2)
static void Rotate (ref Vector2 v, ref Vector2 rotation, out Vector2 result)
 static function equivalent to Rotate(ref Vector2, out Vector2)
static Vector2 Reflect (Vector2 v, Vector2 normal)
 static function equivalent to Reflect(Vector2)
static void Reflect (ref Vector2 v, ref Vector2 normal, out Vector2 result)
 static function equivalent to Reflect(ref Vector2, out Vector2)
static Vector2 Perpendicular (Vector2 v)
 static function equivalent to Perpendicular()
static void Perpendicular (ref Vector2 v, out Vector2 result)
 static function equivalent to Perpendicular(out Vector2)
static Vector2 ProjectOnLine (Vector2 v, Vector2 point, Vector2 direction)
 static function equivalent to ProjectOnLine(Vector2, Vector2)
static void ProjectOnLine (ref Vector2 v, ref Vector2 point, ref Vector2 direction, out Vector2 result)
 static function equivalent to ProjectOnLine(ref Vector2, ref Vector2, out Vector2)
static Vector2 Add (Vector2 v1, Vector2 v2)
 static function equivalent to Add(Vector2)
static void Add (ref Vector2 v1, ref Vector2 v2, out Vector2 result)
 static function equivalent to Add(ref Vector2, out Vector2)
static Vector2 Subtract (Vector2 v1, Vector2 v2)
 static function equivalent to Subtract(Vector2)
static void Subtract (ref Vector2 v1, ref Vector2 v2, out Vector2 result)
 static function equivalent to Subtract(ref Vector2, out Vector2)
static Vector2 Multiply (Vector2 v1, Vector2 v2)
 static function equivalent to Multiply(Vector2)
static void Multiply (ref Vector2 v1, ref Vector2 v2, out Vector2 result)
 static function equivalent to Multiply(ref Vector2, out Vector2)
static Vector2 Multiply (Vector2 v, float f)
 static function equivalent to Multiply(float)
static void Multiply (ref Vector2 v, float f, out Vector2 result)
 static function equivalent to Multiply(float, out Vector2)
static Vector2 Divide (Vector2 v1, Vector2 v2)
 static function equivalent to Divide(Vector2)
static void Divide (ref Vector2 v1, ref Vector2 v2, out Vector2 result)
 static function equivalent to Divide(ref Vector2, out Vector2)
static Vector2 Divide (Vector2 v, float f)
 static function equivalent to Divide(float)
static void Divide (ref Vector2 v, float f, out Vector2 result)
 static function equivalent to Divide(float, out Vector2)
static Vector2 Negate (Vector2 v)
 static function equivalent to Negate()
static void Negate (ref Vector2 v, out Vector2 result)
 static function equivalent to Negate(out Vector2)
static bool operator== (Vector2 v1, Vector2 v2)
 equality operator
static bool operator!= (Vector2 v1, Vector2 v2)
 not equals operator
static Vector2 operator+ (Vector2 v1, Vector2 v2)
 vector addition operator
static Vector2 operator+ (Vector2 v, float f)
 adds a scalar float to each element of a vector
static Vector2 operator+ (float f, Vector2 v)
 adds a scalar float to each element of a vector
static Vector2 operator- (Vector2 v1, Vector2 v2)
 vector subtraction operator
static Vector2 operator- (Vector2 v, float f)
 subtract a scalar float from each element of a vector
static Vector2 operator- (float f, Vector2 v)
 creates a new vector consisting of {f, f}, and then subtracts v from it
static Vector2 operator- (Vector2 v)
 unary minus operator
static Vector2 operator* (Vector2 v1, Vector2 v2)
 multiplication operator
static Vector2 operator* (Vector2 v, float f)
 multiply each element of vector by scalar float
static Vector2 operator* (float f, Vector2 v)
 multiply each element of vector by scalar float
static Vector2 operator/ (Vector2 v1, Vector2 v2)
 division operator
static Vector2 operator/ (Vector2 v, float f)
 divide each element of a vector by a scalar float
static Vector2 operator/ (float f, Vector2 v)
 create a new vector consisting of {f, f} and divide it by vec

Public Attributes

float X
 x
float Y
 y

Static Public Attributes

static readonly Vector2 Zero = new Vector2(0.0f, 0.0f)
 return a new vector with x and y set to 0 and 0
static readonly Vector2 One = new Vector2(1.0f, 1.0f)
 return a new vector with x and y set to 1 and 1
static readonly Vector2 UnitX = new Vector2(1.0f, 0.0f)
 return a new vector with x and y set to 1 and 0
static readonly Vector2 UnitY = new Vector2(0.0f, 1.0f)
 return a new vector with x and y set to 0 and 1

Properties

float R [get, set]
 Red.
float G [get, set]
 Green.
Vector2 Xx [get]
Vector2 Yx [get, set]
Vector2 Xy [get, set]
Vector2 Yy [get]
Vector3 Xy0 [get]
 returns a 3 element vector consisting of the current vector with the z component set to 0
Vector3 Xy1 [get]
 return a 3 element vector consisting of the current vector with the z component set to 1
Vector4 Xy00 [get]
 return a 4 element vector consisting of the current vector with the z and w components set to 0 and 0
Vector4 Xy01 [get]
 return a 4 element vector consisting of the current vector with the z and w components set to 0 and 1
Vector4 Xy10 [get]
 return a 4 element vector consisting of the current vector with the z and w components set to 1 and 0
Vector4 Xy11 [get]
 return a 4 element vector consisting of the current vector with the z and w components set to 1 and 1

Detailed Description

vector of 2 floats


Constructor & Destructor Documentation

Vector2 ( float  x,
float  y 
)

constructor taking two floats

Parameters:
xx
yy
Vector2 ( float  f)

constructor taking one float

Parameters:
ff

Member Function Documentation

Vector2 Abs ( )

element wise absolute value

Returns:
element wise absolute value of this
static Vector2 Abs ( Vector2  v) [static]

static function equivalent to Abs()

Parameters:
vvector
Returns:
element wise absolute value of v
static void Abs ( ref Vector2  v,
out Vector2  result 
) [static]

static function equivalent to Abs(out Vector2)

Parameters:
vvector
resultelement wise absolute value of v
void Abs ( out Vector2  result)

element wise absolute value

Parameters:
resultelement wise absolute value of this
static Vector2 Add ( Vector2  v1,
Vector2  v2 
) [static]

static function equivalent to Add(Vector2)

Parameters:
v1vector 1
v2vector 2
Returns:
v1 + v2
static void Add ( ref Vector2  v1,
ref Vector2  v2,
out Vector2  result 
) [static]

static function equivalent to Add(ref Vector2, out Vector2)

Parameters:
v1vector 1
v2vector 2
resultv1 + v2
Vector2 Add ( Vector2  v)

return this + v

Parameters:
vvector
Returns:
this + v
void Add ( ref Vector2  v,
out Vector2  result 
)

result = this + v

Parameters:
vvector
resultthis + v
float Angle ( Vector2  v)

return the angle between this and v

Parameters:
vvector to get the angle with
Returns:
the angle between this and v
float Angle ( ref Vector2  v)

return the angle between this and v

Parameters:
vvector to get the angle with
Returns:
the angle between this and v
static float Angle ( Vector2  v1,
Vector2  v2 
) [static]

static function equivalent to Angle(Vector2)

Parameters:
v1vector 1
v2vector 2
Returns:
the angle between v1 and v2
static float Angle ( ref Vector2  v1,
ref Vector2  v2 
) [static]

static function equivalent to Angle(ref Vector2)

Parameters:
v1vector 1
v2vector 2
Returns:
the angle between v1 and v2
Vector2 Clamp ( Vector2  min,
Vector2  max 
)

element wise clamp

Parameters:
minmin values to clamp against
maxmax values to clamp against
Returns:
a new vector consisting of each element of this clamped between min and max
void Clamp ( ref Vector2  min,
ref Vector2  max,
out Vector2  result 
)

element wise clamp

Parameters:
minmin values to clamp against
maxmax values to clamp against
resulta new vector consisting of each element of this clamped between min and max
Vector2 Clamp ( float  min,
float  max 
)

element wise clamp

Parameters:
minmin value to clamp against
maxmax value to clamp against
Returns:
a new vector consisting of each element of this clamped between min and max
static Vector2 Clamp ( Vector2  v,
Vector2  min,
Vector2  max 
) [static]

static function equivalent to Clamp(Vector2, Vector2)

Parameters:
vvector
minmin values to clamp against
maxmax values to clamp against
Returns:
a new vector consisting of each element of v clamped between min and max
static void Clamp ( ref Vector2  v,
ref Vector2  min,
ref Vector2  max,
out Vector2  result 
) [static]

static function equivalent to Clamp(ref Vector2, ref Vector2, out Vector2)

Parameters:
vvector
minmin values to clamp against
maxmax values to clamp against
resulta new vector consisting of each element of v clamped between min and max
static Vector2 Clamp ( Vector2  v,
float  min,
float  max 
) [static]

static function equivalent to Clamp(float, float)

Parameters:
vvector
minmin value to clamp against
maxmax value to clamp against
Returns:
a new vector consisting of each element of v clamped between min and max
void Clamp ( float  min,
float  max,
out Vector2  result 
)

element wise clamp

Parameters:
minmin value to clamp against
maxmax value to clamp against
resulta new vector consisting of each element of this clamped between min and max
static void Clamp ( ref Vector2  v,
float  min,
float  max,
out Vector2  result 
) [static]

static function equivalent to Clamp(float, float, out Vector2)

Parameters:
vvector
minmin value to clamp against
maxmax value to clamp against
resulta new vector consisting of each element of v clamped between min and max
float Determinant ( ref Vector2  v)

return the determinant of the 2x2 matrix formed by this and v

Parameters:
vvector used to form the 2x2 matrix to take the determinant of
Returns:
the determinant of the 2x2 matrix formed by this and v
static float Determinant ( Vector2  v1,
Vector2  v2 
) [static]

static function equivalent to Determinant(Vector2 v)

Parameters:
v1vector 1
v2vector 2
Returns:
the determinant of the 2x2 matrix formed by v1 and v2
static float Determinant ( ref Vector2  v1,
ref Vector2  v2 
) [static]

static function equivalent to Determinant(ref Vector2 v)

Parameters:
v1vector 1
v2vector 2
Returns:
the determinant of the 2x2 matrix formed by v1 and v2
float Determinant ( Vector2  v)

return the determinant of the 2x2 matrix formed by this and v

Parameters:
vvector used to form the 2x2 matrix to take the determinant of
Returns:
the determinant of the 2x2 matrix formed by this and v
float Distance ( ref Vector2  v)

get the distance between this and another vector

Parameters:
vthe vector to get the distance to
Returns:
the distance bwteen this and the other vector
static float Distance ( Vector2  v1,
Vector2  v2 
) [static]

static function equivalent to Distance(Vector2)

Parameters:
v1vector 1
v2vector 2
Returns:
the distance bwteen v1 and v2
static float Distance ( ref Vector2  v1,
ref Vector2  v2 
) [static]

static function equivalent to Distance(ref Vector2)

Parameters:
v1vector 1
v2vector 2
Returns:
the distance bwteen v1 and v2
float Distance ( Vector2  v)

get the distance between this and another vector

Parameters:
vthe vector to get the distance to
Returns:
the distance bwteen this and the other vector
float DistanceSquared ( Vector2  v)

get the distance squared between this and another vector

Parameters:
vthe vector to get the distance squared to
Returns:
the distance between this and the other vector squared
static float DistanceSquared ( Vector2  v1,
Vector2  v2 
) [static]

static function equivalent to DistanceSquared(Vector2)

Parameters:
v1vector 1
v2vector 2
Returns:
the distance between v1 and v2 squared
static float DistanceSquared ( ref Vector2  v1,
ref Vector2  v2 
) [static]

static function equivalent to DistanceSquared(ref Vector2)

Parameters:
v1vector 1
v2vector 2
Returns:
the distance between v1 and v2 squared
float DistanceSquared ( ref Vector2  v)

get the distance squared between this and another vector

Parameters:
vthe vector to get the distance squared to
Returns:
the distance between this and the other vector squared
static Vector2 Divide ( Vector2  v1,
Vector2  v2 
) [static]

static function equivalent to Divide(Vector2)

Parameters:
v1vector 1
v2vector 2
Returns:
v1 / v2
static void Divide ( ref Vector2  v1,
ref Vector2  v2,
out Vector2  result 
) [static]

static function equivalent to Divide(ref Vector2, out Vector2)

Parameters:
v1vector 1
v2vector 2
resultv1 / v2
static Vector2 Divide ( Vector2  v,
float  f 
) [static]

static function equivalent to Divide(float)

Parameters:
vvector
fscalar
Returns:
v / f
static void Divide ( ref Vector2  v,
float  f,
out Vector2  result 
) [static]

static function equivalent to Divide(float, out Vector2)

Parameters:
vvector
fscalar
resultv / f
Vector2 Divide ( Vector2  v)

return this / v

Parameters:
vvector
Returns:
this / v
void Divide ( ref Vector2  v,
out Vector2  result 
)

result = this / v

Parameters:
vvector
resultthis / v
Vector2 Divide ( float  f)

return this / f

Parameters:
fscalar
Returns:
this / f
void Divide ( float  f,
out Vector2  result 
)

result = this / f

Parameters:
fscalar
resultthis / f
float Dot ( ref Vector2  v)

dot product of this and v

Parameters:
vvector to take the dot product with
Returns:
dot product of this and v
static float Dot ( Vector2  v1,
Vector2  v2 
) [static]

static function equivalent to Dot(Vector2)

Parameters:
v1vector 1
v2vector 2
Returns:
dot product of v1 and v2
static float Dot ( ref Vector2  v1,
ref Vector2  v2 
) [static]

static function equivalent to Dot(ref Vector2)

Parameters:
v1vector 1
v2vector 2
Returns:
dot product of v1 and v2
float Dot ( Vector2  v)

dot product of this and v

Parameters:
vvector to take the dot product with
Returns:
dot product of this and v
bool Equals ( Vector2  v,
float  epsilon 
)

equality test with an epsilon

Parameters:
vthe vector to compare this to
epsilonthe epsilon to use in comparison
Returns:
true if for every element n, abs(this[n] - v[n]) <= epsilon, false otherwise
bool Equals ( Vector2  v)

equality test

Parameters:
vthe vector to compare this to
Returns:
true if this == v, false otherwise
override bool Equals ( Object  o)

equality test

Parameters:
othe object to compare this to
Returns:
true if this == o, false otherwise
override int GetHashCode ( )

gets the hash code for this vector

Returns:
integer hash code
bool IsInfinity ( )

test if any elements of this are Infinity

Returns:
true if any elements of this are Infinity, false otherwise
bool IsNaN ( )

test if any of the elements of this are NaN

Returns:
true is any elements of this are NaN, false otherwise
bool IsOne ( )

test if all elements of this are one

Returns:
true if all elements of this are one, false otherwise
bool IsUnit ( float  epsilon)

unit vector test

Parameters:
epsilonepsilon used to test
Returns:
true if the absolute value of the vector length minus one is <= epsilon, false otherwise
bool IsZero ( )

test if all elements of this are zero

Returns:
true if all elements of this are zero, false otherwise
static float Length ( Vector2  v) [static]

static function equivalent to Length()

Parameters:
vvector
Returns:
the length of the vector
static float Length ( ref Vector2  v) [static]

static function equivalent to Length()

Parameters:
vvector
Returns:
the length of the vector
float Length ( )

return the length of this vector

Returns:
the length of this vector
float LengthSquared ( )

return the length squared of this vector

Returns:
the length squared of this vector
static float LengthSquared ( Vector2  v) [static]

static function equivalent to LengthSquared()

Parameters:
vvector
Returns:
the length squared of the vector
static float LengthSquared ( ref Vector2  v) [static]

static function equivalent to LengthSquared()

Parameters:
vvector
Returns:
the length squared of the vector
void Lerp ( ref Vector2  v,
float  f,
out Vector2  result 
)

lerp between this and the other vector

Parameters:
vthe other vector to lerp to
flerp amount
resulta Vector2 where each element is the result of lerping f between the corresponding elements of this and other
static Vector2 Lerp ( Vector2  v1,
Vector2  v2,
float  f 
) [static]

static function equivalent to Lerp(Vector2, float)

Parameters:
v1vector 1
v2vector 2
flerp amount
Returns:
a Vector2 where each element is the result of lerping f between the corresponding elements of v1 and v2
static void Lerp ( ref Vector2  v1,
ref Vector2  v2,
float  f,
out Vector2  result 
) [static]

static function equivalent to Lerp(ref Vector2, float, out Vector2)

Parameters:
v1vector 1
v2vector 2
flerp amount
resulta Vector2 where each element is the result of lerping f between the corresponding elements of v1 and v2
Vector2 Lerp ( Vector2  v,
float  f 
)

lerp between this and the other vector

Parameters:
vthe other vector to lerp to
flerp amount
Returns:
a Vector2 where each element is the result of lerping f between the corresponding elements of this and other
Vector2 Max ( Vector2  v)

element wise max

Parameters:
vvector to compare to this
Returns:
the max of this and v
void Max ( ref Vector2  v,
out Vector2  result 
)

element wise max

Parameters:
vvector to compare to this
resultthe max of this and v
Vector2 Max ( float  f)

element wise max

Parameters:
fscalar to compare to this
Returns:
the max of this and f
void Max ( float  f,
out Vector2  result 
)

element wise max

Parameters:
fscalar to compare to this
resultthe max of this and f
static Vector2 Max ( Vector2  v1,
Vector2  v2 
) [static]

static function equivalent to Max(Vector2)

Parameters:
v1vector 1
v2vector 2
Returns:
the max of v1 and v2
static void Max ( ref Vector2  v1,
ref Vector2  v2,
out Vector2  result 
) [static]

static function equivalent to Max(ref Vector2, out Vector2)

Parameters:
v1vector 1
v2vector 2
resultthe max of v1 and v2
static Vector2 Max ( Vector2  v,
float  f 
) [static]

static function equivalent to Max(float)

Parameters:
vvector
fscalar
Returns:
the max of v and f
static void Max ( ref Vector2  v,
float  f,
out Vector2  result 
) [static]

static function equivalent to Max(float, out Vector2)

Parameters:
vvector
fscalar
resultthe max of v and f
void Min ( ref Vector2  v,
out Vector2  result 
)

element wise min

Parameters:
vvector to compare to this
resultthe min of this and v
void Min ( float  f,
out Vector2  result 
)

element wise min

Parameters:
fscalar to compare to this
resultthe min of this and f
static Vector2 Min ( Vector2  v,
float  f 
) [static]

static function equivalent to Min(float)

Parameters:
vvector
fscalar
Returns:
the min of v and f
Vector2 Min ( float  f)

element wise min

Parameters:
fscalar to compare to this
Returns:
the min of this and f
static Vector2 Min ( Vector2  v1,
Vector2  v2 
) [static]

static function equivalent to Min(Vector2)

Parameters:
v1vector 1
v2vector 2
Returns:
the min of v1 and v2
static void Min ( ref Vector2  v1,
ref Vector2  v2,
out Vector2  result 
) [static]

static function equivalent to Min(ref Vector2, out Vector2)

Parameters:
v1vector 1
v2vector 2
resultthe min of v1 and v2
static void Min ( ref Vector2  v,
float  f,
out Vector2  result 
) [static]

static function equivalent to Min(float, out Vector2)

Parameters:
vvector
fscalar
resultthe min of v and f
Vector2 Min ( Vector2  v)

element wise min

Parameters:
vvector to compare to this
Returns:
the min of this and v
Vector2 MoveTo ( Vector2  v,
float  length 
)

move to target vector by specified length

Parameters:
vtarget vector
lengthstep length
Returns:
a new vector moved to target vector by specified length
void MoveTo ( ref Vector2  v,
float  length,
out Vector2  result 
)

move to target vector by specified angle

Parameters:
vtarget vector
lengthstep length
resulta new vector moved to target vector by specified length
static Vector2 MoveTo ( Vector2  v1,
Vector2  v2,
float  length 
) [static]

static function equivalent to MoveTo(Vector2, float)

Parameters:
v1vector 1
v2vector 2
lengthstep length
Returns:
a new vector moved to target vector by specified length
static void MoveTo ( ref Vector2  v1,
ref Vector2  v2,
float  length,
out Vector2  result 
) [static]

static function equivalent to MoveTo(ref Vector2, float, out Vector2)

Parameters:
v1vector 1
v2vector 2
lengthstep length
resulta new vector moved to target vector by specified length
static Vector2 Multiply ( Vector2  v1,
Vector2  v2 
) [static]

static function equivalent to Multiply(Vector2)

Parameters:
v1vector 1
v2vector 2
Returns:
v1 * v2
static void Multiply ( ref Vector2  v,
float  f,
out Vector2  result 
) [static]

static function equivalent to Multiply(float, out Vector2)

Parameters:
vvector
fscalar
resultv * f
static void Multiply ( ref Vector2  v1,
ref Vector2  v2,
out Vector2  result 
) [static]

static function equivalent to Multiply(ref Vector2, out Vector2)

Parameters:
v1vector 1
v2vector 2
resultv1 * v2
Vector2 Multiply ( Vector2  v)

return this * v

Parameters:
vvector
Returns:
this * v
static Vector2 Multiply ( Vector2  v,
float  f 
) [static]

static function equivalent to Multiply(float)

Parameters:
vvector
fscalar
Returns:
v * f
void Multiply ( ref Vector2  v,
out Vector2  result 
)

result = this * v

Parameters:
vvector
resultthis * v
Vector2 Multiply ( float  f)

return this * f

Parameters:
fscalar
Returns:
this * f
void Multiply ( float  f,
out Vector2  result 
)

result = this * f

Parameters:
fscalar
resultthis * f
void Negate ( out Vector2  result)

result = -this

Parameters:
result-this
static Vector2 Negate ( Vector2  v) [static]

static function equivalent to Negate()

Parameters:
vvector
Returns:
-v
static void Negate ( ref Vector2  v,
out Vector2  result 
) [static]

static function equivalent to Negate(out Vector2)

Parameters:
vvector
result-v
Vector2 Negate ( )

return -this

Returns:
-this
Vector2 Normalize ( )

return this vector normalized

Returns:
this vector normalized
static Vector2 Normalize ( Vector2  v) [static]

static function equivalent to Normalize()

Parameters:
vvector
Returns:
the vector normalized
static void Normalize ( ref Vector2  v,
out Vector2  result 
) [static]

static function equivalent to Normalize(out Vector2)

Parameters:
vvector
resultthe vector normalized
void Normalize ( out Vector2  result)

return this vector normalized

Parameters:
resultthis vector normalized
static bool operator!= ( Vector2  v1,
Vector2  v2 
) [static]

not equals operator

Parameters:
v1vector 1
v2vector 2
Returns:
true if vector 1 != vector 2, false otherwise
static Vector2 operator* ( Vector2  v1,
Vector2  v2 
) [static]

multiplication operator

Parameters:
v1vector 1
v2vector 2
Returns:
vector 1 * vector 2
static Vector2 operator* ( float  f,
Vector2  v 
) [static]

multiply each element of vector by scalar float

Parameters:
fthe scalar to multiply each element of the vector by
vthe vector to multiply
Returns:
a new vector consisting of each element of vector multiplied by f
static Vector2 operator* ( Vector2  v,
float  f 
) [static]

multiply each element of vector by scalar float

Parameters:
vthe vector to multiply
fthe scalar to multiply each element of the vector by
Returns:
a new vector consisting of each element of vector multiplied by f
static Vector2 operator+ ( Vector2  v1,
Vector2  v2 
) [static]

vector addition operator

Parameters:
v1vector 1
v2vector 2
Returns:
vector 1 + vector 2
static Vector2 operator+ ( Vector2  v,
float  f 
) [static]

adds a scalar float to each element of a vector

Parameters:
vthe vector to add
fthe scalar float to add each element of the vector
Returns:
a new vector with f added to each element of v
static Vector2 operator+ ( float  f,
Vector2  v 
) [static]

adds a scalar float to each element of a vector

Parameters:
fthe scalar float to add each element of the vector
vthe vector to add
Returns:
a new vector with f added to each element of v
static Vector2 operator- ( Vector2  v1,
Vector2  v2 
) [static]

vector subtraction operator

Parameters:
v1vector 1
v2vector 2
Returns:
vector 1 - vector 2
static Vector2 operator- ( Vector2  v,
float  f 
) [static]

subtract a scalar float from each element of a vector

Parameters:
vthe vector to subtract from
fthe scalar float to subtract from each element of the vector
Returns:
a new vector with f subtracted from each element of v
static Vector2 operator- ( float  f,
Vector2  v 
) [static]

creates a new vector consisting of {f, f}, and then subtracts v from it

Parameters:
fthe scalar that we subtract v from
vthe vector to subtract
Returns:
a new vector consisting of v subtracted from the vector {f, f}
static Vector2 operator- ( Vector2  v) [static]

unary minus operator

Parameters:
vthe vector to negate
Returns:
unary minus applied to each member of v
static Vector2 operator/ ( Vector2  v1,
Vector2  v2 
) [static]

division operator

Parameters:
v1vector 1
v2vector 2
Returns:
vector 1 / vector 2
static Vector2 operator/ ( Vector2  v,
float  f 
) [static]

divide each element of a vector by a scalar float

Parameters:
vthe vector to divide by scalar
fthe scalar to divide by
Returns:
a new Vector2 consisting of each element of v divided by f
static Vector2 operator/ ( float  f,
Vector2  v 
) [static]

create a new vector consisting of {f, f} and divide it by vec

Parameters:
fthe scalar to divide by vector
vthe vector to divide by
Returns:
a new vector {f, f} divided by v
static bool operator== ( Vector2  v1,
Vector2  v2 
) [static]

equality operator

Parameters:
v1vector 1
v2vector 2
Returns:
true if vector 1 == vector 2, false otherwise
static Vector2 Perpendicular ( Vector2  v) [static]

static function equivalent to Perpendicular()

Parameters:
vvector
Returns:
a vector perpendicular to v
static void Perpendicular ( ref Vector2  v,
out Vector2  result 
) [static]

static function equivalent to Perpendicular(out Vector2)

Parameters:
vvector
resulta vector perpendicular to v
void Perpendicular ( out Vector2  result)

return this rotated by +pi/2

Parameters:
resultreturn this rotated by +pi/2 (this is different from Vector3.Perpendicular)
Vector2 Perpendicular ( )

return a vector perpendicular to this

Returns:
a vector perpendicular to this
static void ProjectOnLine ( ref Vector2  v,
ref Vector2  point,
ref Vector2  direction,
out Vector2  result 
) [static]

static function equivalent to ProjectOnLine(ref Vector2, ref Vector2, out Vector2)

Parameters:
vvector
pointpoint of the line to project onto
directiondirection of the line to project onto
resultprojection of v onto the line (point,direction)
void ProjectOnLine ( ref Vector2  point,
ref Vector2  direction,
out Vector2  result 
)

project this onto the line (point,direction)

Parameters:
pointpoint of the line to project onto
directiondirection of the line to project onto
resultprojection of this onto the line (point,direction)
Vector2 ProjectOnLine ( Vector2  point,
Vector2  direction 
)

project this onto the line (point,direction)

Parameters:
pointpoint of the line to project onto
directiondirection of the line to project onto
Returns:
projection of this onto the line (point,direction)
static Vector2 ProjectOnLine ( Vector2  v,
Vector2  point,
Vector2  direction 
) [static]

static function equivalent to ProjectOnLine(Vector2, Vector2)

Parameters:
vvector
pointpoint of the line to project onto
directiondirection of the line to project onto
Returns:
projection of v onto the line (point,direction)
static void Reflect ( ref Vector2  v,
ref Vector2  normal,
out Vector2  result 
) [static]

static function equivalent to Reflect(ref Vector2, out Vector2)

Parameters:
vvector
normalthe vector to reflect about
resultthe vector reflected about normal
Vector2 Reflect ( Vector2  normal)

return this vector reflected about normal

Parameters:
normalthe vector to reflect about
Returns:
this vector reflected about normal
void Reflect ( ref Vector2  normal,
out Vector2  result 
)

return this vector reflected about normal

Parameters:
normalthe vector to reflect about
resultthis vector reflected about normal
static Vector2 Reflect ( Vector2  v,
Vector2  normal 
) [static]

static function equivalent to Reflect(Vector2)

Parameters:
vvector
normalthe vector to reflect about
Returns:
the vector reflected about normal
Vector2 Repeat ( float  min,
float  max 
)

element wise repeat

Parameters:
minmin value to repeat over
maxmax value to repeat over
Returns:
a new vector consisting of each element of this repeated between min and max
void Repeat ( ref Vector2  min,
ref Vector2  max,
out Vector2  result 
)

element wise repeat

Parameters:
minmin values to repeat over
maxmax values to repeat over
resulta new vector consisting of each element of this repeated between min and max
Vector2 Repeat ( Vector2  min,
Vector2  max 
)

element wise repeat

Parameters:
minmin values to repeat over
maxmax values to repeat over
Returns:
a new vector consisting of each element of this repeated between min and max
static Vector2 Repeat ( Vector2  v,
float  min,
float  max 
) [static]

static function equivalent to Repeat(float, float)

Parameters:
vvector
minmin value to repeat over
maxmax value to repeat over
Returns:
a new vector consisting of each element of v repeated between min and max
static void Repeat ( ref Vector2  v,
ref Vector2  min,
ref Vector2  max,
out Vector2  result 
) [static]

static function equivalent to Repeat(ref Vector2, ref Vector2, out Vector2)

Parameters:
vvector
minmin values to repeat over
maxmax values to repeat over
resulta new vector consisting of each element of v repeated between min and max
static void Repeat ( ref Vector2  v,
float  min,
float  max,
out Vector2  result 
) [static]

static function equivalent to Repeat(float, float, out Vector2)

Parameters:
vvector
minmin value to repeat over
maxmax value to repeat over
resulta new vector consisting of each element of v repeated between min and max
static Vector2 Repeat ( Vector2  v,
Vector2  min,
Vector2  max 
) [static]

static function equivalent to Repeat(Vector2, Vector2)

Parameters:
vvector
minmin values to repeat over
maxmax values to repeat over
Returns:
a new vector consisting of each element of v repeated between min and max
void Repeat ( float  min,
float  max,
out Vector2  result 
)

element wise repeat

Parameters:
minmin value to repeat over
maxmax value to repeat over
resulta new vector consisting of each element of this repeated between min and max
static void Rotate ( ref Vector2  v,
ref Vector2  rotation,
out Vector2  result 
) [static]

static function equivalent to Rotate(ref Vector2, out Vector2)

Parameters:
vvector
rotationa vector containing the cos and sin of the angle to rotate by
resultthe vector rotated by angle
static Vector2 Rotate ( Vector2  v,
Vector2  rotation 
) [static]

static function equivalent to Rotate(Vector2)

Parameters:
vvector
rotationa vector containing the cos and sin of the angle to rotate by
Returns:
the vector rotated by angle
void Rotate ( ref Vector2  rotation,
out Vector2  result 
)

return this vector rotated by angle

Parameters:
rotationa vector containing the cos and sin of the angle to rotate by
resultthis vector rotated by angle
Vector2 Rotate ( Vector2  rotation)

return this vector rotated by angle

Parameters:
rotationa vector containing the cos and sin of the angle to rotate by
Returns:
this vector rotated by angle
Vector2 Rotate ( float  angle)

return this vector rotated by angle

Parameters:
angleangle to rotate by
Returns:
this vector rotated by angle
void Rotate ( float  angle,
out Vector2  result 
)

return this vector rotated by angle

Parameters:
angleangle to rotate by
resultthis vector rotated by angle
static Vector2 Rotate ( Vector2  v,
float  angle 
) [static]

static function equivalent to Rotate(float)

Parameters:
vvector
angleangle to rotate by
Returns:
the vector rotated by angle
static void Rotate ( ref Vector2  v,
float  angle,
out Vector2  result 
) [static]

static function equivalent to Rotate(float, out Vector2)

Parameters:
vvector
angleangle to rotate by
resultthe vector rotated by angle
static void Rotation ( float  angle,
out Vector2  result 
) [static]

return a new vector that breaks a rotation angle into its x and y components

Parameters:
anglethe rotation angle
resulta new vector that breaks a rotation angle into its x and y components
static Vector2 Rotation ( float  angle) [static]

return a new vector that breaks a rotation angle into its x and y components

Parameters:
anglethe rotation angle
Returns:
a new vector that breaks a rotation angle into its x and y components
static Vector2 Slerp ( Vector2  v1,
Vector2  v2,
float  f 
) [static]

static function equivalent to Slerp(Vector2, float)

Parameters:
v1vector 1
v2vector 2
fslerp amount
Returns:
slerp between v1 and v2
static void Slerp ( ref Vector2  v1,
ref Vector2  v2,
float  f,
out Vector2  result 
) [static]

static function equivalent to Slerp(ref Vector2, float, out Vector2)

Parameters:
v1vector 1
v2vector 2
fslerp amount
resultslerp between v1 and v2
Vector2 Slerp ( Vector2  v,
float  f 
)

slerp between this and the other vector

Parameters:
vthe other vector to slerp to
fslerp amount
Returns:
slerp between this and v
void Slerp ( ref Vector2  v,
float  f,
out Vector2  result 
)

slerp between this and the other vector

Parameters:
vthe other vector to slerp to
fslerp amount
resultslerp between this and v
static void Subtract ( ref Vector2  v1,
ref Vector2  v2,
out Vector2  result 
) [static]

static function equivalent to Subtract(ref Vector2, out Vector2)

Parameters:
v1vector 1
v2vector 2
resultv1 - v2
static Vector2 Subtract ( Vector2  v1,
Vector2  v2 
) [static]

static function equivalent to Subtract(Vector2)

Parameters:
v1vector 1
v2vector 2
Returns:
v1 - v2
Vector2 Subtract ( Vector2  v)

return this - v

Parameters:
vvector
Returns:
this - v
void Subtract ( ref Vector2  v,
out Vector2  result 
)

result = this - v

Parameters:
vvector
resultthis - v
override string ToString ( )

convert vector to string

Returns:
string representation of the vector
Vector2 TurnTo ( Vector2  v,
float  angle 
)

turn to target vector by specified angle

Parameters:
vtarget vector
anglestep angle
Returns:
a new vector turned to target vector by specified angle
static void TurnTo ( ref Vector2  v1,
ref Vector2  v2,
float  angle,
out Vector2  result 
) [static]

static function equivalent to TurnTo(ref Vector2, float, out Vector2)

Parameters:
v1vector 1
v2vector 2
anglestep angle
resulta new vector turned to target vector by specified angle
void TurnTo ( ref Vector2  v,
float  angle,
out Vector2  result 
)

turn to target vector by specified angle

Parameters:
vtarget vector
anglestep angle
resulta new vector turned to target vector by specified angle
static Vector2 TurnTo ( Vector2  v1,
Vector2  v2,
float  angle 
) [static]

static function equivalent to TurnTo(Vector2, float)

Parameters:
v1vector 1
v2vector 2
anglestep angle
Returns:
a new vector turned to target vector by specified angle

Member Data Documentation

readonly Vector2 One = new Vector2(1.0f, 1.0f) [static]

return a new vector with x and y set to 1 and 1

Returns:
a new vector with x and y set to 1 and 1
readonly Vector2 UnitX = new Vector2(1.0f, 0.0f) [static]

return a new vector with x and y set to 1 and 0

Returns:
a new vector with x and y set to 1 and 0
readonly Vector2 UnitY = new Vector2(0.0f, 1.0f) [static]

return a new vector with x and y set to 0 and 1

Returns:
a new vector with x and y set to 0 and 1
float X

x

float Y

y

readonly Vector2 Zero = new Vector2(0.0f, 0.0f) [static]

return a new vector with x and y set to 0 and 0

Returns:
a new vector with x and y set to 0 and 0

Property Documentation

float G [get, set]

Green.

float R [get, set]

Red.

Vector2 Xx [get]

return a new vector consisting of the current vector's x, x values

Returns:
a new vector consisting of the current vector's x, x values
Vector2 Xy [get, set]

return a new vector consisting of, or set, the current vector's x, y values

Returns:
a new vector consisting of the current vector's x, y values
Vector3 Xy0 [get]

returns a 3 element vector consisting of the current vector with the z component set to 0

Returns:
a 3 element vector consisting of the current vector with the z component set to 0
Vector4 Xy00 [get]

return a 4 element vector consisting of the current vector with the z and w components set to 0 and 0

Returns:
a 4 element vector consisting of the current vector with the z and w components set to 0 and 0
Vector4 Xy01 [get]

return a 4 element vector consisting of the current vector with the z and w components set to 0 and 1

Returns:
a 4 element vector consisting of the current vector with the z and w components set to 0 and 1
Vector3 Xy1 [get]

return a 3 element vector consisting of the current vector with the z component set to 1

Returns:
a 3 element vector consisting of the current vector with the z component set to 1
Vector4 Xy10 [get]

return a 4 element vector consisting of the current vector with the z and w components set to 1 and 0

Returns:
a 4 element vector consisting of the current vector with the z and w components set to 1 and 0
Vector4 Xy11 [get]

return a 4 element vector consisting of the current vector with the z and w components set to 1 and 1

Returns:
a 4 element vector consisting of the current vector with the z and w components set to 1 and 1
Vector2 Yx [get, set]

return a new vector consisting of, or set, the current vector's y, x values

Returns:
a new vector consisting of the current vector's y, x values
Vector2 Yy [get]

return a new vector consisting of the current vector's y, y values

Returns:
a new vector consisting of the current vector's y, y values