OpenTK.Vector2 Struct Reference

Represents a 2D vector using two single-precision floating-point numbers. More...

List of all members.

Public Member Functions

 Vector2 (float x, float y)
 Constructs a new Vector2.
 Vector2 (Vector2 v)
 Constructs a new Vector2 from the given Vector2.
 Vector2 (Vector3 v)
 Constructs a new Vector2 from the given Vector3.
 Vector2 (Vector4 v)
 Constructs a new Vector2 from the given Vector4.
void Add (Vector2 right)
 Add the Vector passed as parameter to this instance.
void Add (ref Vector2 right)
 Add the Vector passed as parameter to this instance.
void Sub (Vector2 right)
 Subtract the Vector passed as parameter from this instance.
void Sub (ref Vector2 right)
 Subtract the Vector passed as parameter from this instance.
void Mult (float f)
 Multiply this instance by a scalar.
void Div (float f)
 Divide this instance by a scalar.
void Normalize ()
 Scales the Vector2 to unit length.
void NormalizeFast ()
 Scales the Vector2 to approximately unit length.
void Scale (float sx, float sy)
 Scales the current Vector2 by the given amounts.
void Scale (Vector2 scale)
 Scales this instance by the given parameter.
void Scale (ref Vector2 scale)
 Scales this instance by the given parameter.
override string ToString ()
 Returns a System.String that represents the current Vector2.
override int GetHashCode ()
 Returns the hashcode for this instance.
override bool Equals (object obj)
 Indicates whether this instance and a specified object are equal.
bool Equals (Vector2 other)
 Indicates whether the current vector is equal to another vector.

Static Public Member Functions

static Vector2 Sub (Vector2 a, Vector2 b)
 Subtract one Vector from another.
static void Sub (ref Vector2 a, ref Vector2 b, out Vector2 result)
 Subtract one Vector from another.
static Vector2 Mult (Vector2 a, float f)
 Multiply a vector and a scalar.
static void Mult (ref Vector2 a, float f, out Vector2 result)
 Multiply a vector and a scalar.
static Vector2 Div (Vector2 a, float f)
 Divide a vector by a scalar.
static void Div (ref Vector2 a, float f, out Vector2 result)
 Divide a vector by a scalar.
static Vector2 Add (Vector2 a, Vector2 b)
 Adds two vectors.
static void Add (ref Vector2 a, ref Vector2 b, out Vector2 result)
 Adds two vectors.
static Vector2 Subtract (Vector2 a, Vector2 b)
 Subtract one Vector from another.
static void Subtract (ref Vector2 a, ref Vector2 b, out Vector2 result)
 Subtract one Vector from another.
static Vector2 Multiply (Vector2 vector, float scale)
 Multiplies a vector by a scalar.
static void Multiply (ref Vector2 vector, float scale, out Vector2 result)
 Multiplies a vector by a scalar.
static Vector2 Multiply (Vector2 vector, Vector2 scale)
 Multiplies a vector by the components a vector (scale).
static void Multiply (ref Vector2 vector, ref Vector2 scale, out Vector2 result)
 Multiplies a vector by the components of a vector (scale).
static Vector2 Divide (Vector2 vector, float scale)
 Divides a vector by a scalar.
static void Divide (ref Vector2 vector, float scale, out Vector2 result)
 Divides a vector by a scalar.
static Vector2 Divide (Vector2 vector, Vector2 scale)
 Divides a vector by the components of a vector (scale).
static void Divide (ref Vector2 vector, ref Vector2 scale, out Vector2 result)
 Divide a vector by the components of a vector (scale).
static Vector2 ComponentMin (Vector2 a, Vector2 b)
 Calculate the component-wise minimum of two vectors.
static void ComponentMin (ref Vector2 a, ref Vector2 b, out Vector2 result)
 Calculate the component-wise minimum of two vectors.
static Vector2 ComponentMax (Vector2 a, Vector2 b)
 Calculate the component-wise maximum of two vectors.
static void ComponentMax (ref Vector2 a, ref Vector2 b, out Vector2 result)
 Calculate the component-wise maximum of two vectors.
static Vector2 Min (Vector2 left, Vector2 right)
 Returns the Vector3 with the minimum magnitude.
static Vector2 Max (Vector2 left, Vector2 right)
 Returns the Vector3 with the minimum magnitude.
static Vector2 Clamp (Vector2 vec, Vector2 min, Vector2 max)
 Clamp a vector to the given minimum and maximum vectors.
static void Clamp (ref Vector2 vec, ref Vector2 min, ref Vector2 max, out Vector2 result)
 Clamp a vector to the given minimum and maximum vectors.
static Vector2 Normalize (Vector2 vec)
 Scale a vector to unit length.
static void Normalize (ref Vector2 vec, out Vector2 result)
 Scale a vector to unit length.
static Vector2 NormalizeFast (Vector2 vec)
 Scale a vector to approximately unit length.
static void NormalizeFast (ref Vector2 vec, out Vector2 result)
 Scale a vector to approximately unit length.
static float Dot (Vector2 left, Vector2 right)
 Calculate the dot (scalar) product of two vectors.
static void Dot (ref Vector2 left, ref Vector2 right, out float result)
 Calculate the dot (scalar) product of two vectors.
static Vector2 Lerp (Vector2 a, Vector2 b, float blend)
 Returns a new Vector that is the linear blend of the 2 given Vectors.
static void Lerp (ref Vector2 a, ref Vector2 b, float blend, out Vector2 result)
 Returns a new Vector that is the linear blend of the 2 given Vectors.
static Vector2 BaryCentric (Vector2 a, Vector2 b, Vector2 c, float u, float v)
 Interpolate 3 Vectors using Barycentric coordinates.
static void BaryCentric (ref Vector2 a, ref Vector2 b, ref Vector2 c, float u, float v, out Vector2 result)
 Interpolate 3 Vectors using Barycentric coordinates.
static Vector2 Transform (Vector2 vec, Quaternion quat)
 Transforms a vector by a quaternion rotation.
static void Transform (ref Vector2 vec, ref Quaternion quat, out Vector2 result)
 Transforms a vector by a quaternion rotation.
static Vector2 operator+ (Vector2 left, Vector2 right)
 Adds the specified instances.
static Vector2 operator- (Vector2 left, Vector2 right)
 Subtracts the specified instances.
static Vector2 operator- (Vector2 vec)
 Negates the specified instance.
static Vector2 operator* (Vector2 vec, float scale)
 Multiplies the specified instance by a scalar.
static Vector2 operator* (float scale, Vector2 vec)
 Multiplies the specified instance by a scalar.
static Vector2 operator/ (Vector2 vec, float scale)
 Divides the specified instance by a scalar.
static bool operator== (Vector2 left, Vector2 right)
 Compares the specified instances for equality.
static bool operator!= (Vector2 left, Vector2 right)
 Compares the specified instances for inequality.

Public Attributes

float X
 The X component of the Vector2.
float Y
 The Y component of the Vector2.

Static Public Attributes

static readonly Vector2 UnitX = new Vector2(1, 0)
 Defines a unit-length Vector2 that points towards the X-axis.
static readonly Vector2 UnitY = new Vector2(0, 1)
 Defines a unit-length Vector2 that points towards the Y-axis.
static readonly Vector2 Zero = new Vector2(0, 0)
 Defines a zero-length Vector2.
static readonly Vector2 One = new Vector2(1, 1)
 Defines an instance with all components set to 1.
static readonly int SizeInBytes = Marshal.SizeOf(new Vector2())
 Defines the size of the Vector2 struct in bytes.

Properties

float Length [get]
 Gets the length (magnitude) of the vector.
float LengthFast [get]
 Gets an approximation of the vector length (magnitude).
float LengthSquared [get]
 Gets the square of the vector length (magnitude).
Vector2 PerpendicularRight [get]
 Gets the perpendicular vector on the right side of this vector.
Vector2 PerpendicularLeft [get]
 Gets the perpendicular vector on the left side of this vector.

Detailed Description

Represents a 2D vector using two single-precision floating-point numbers.

The Vector2 structure is suitable for interoperation with unmanaged code requiring two consecutive floats.

Definition at line 35 of file Vector2.cs.


Constructor & Destructor Documentation

OpenTK.Vector2.Vector2 ( float  x,
float  y 
)

Constructs a new Vector2.

Parameters:
x The x coordinate of the net Vector2.
y The y coordinate of the net Vector2.

Definition at line 58 of file Vector2.cs.

00059         {
00060             X = x;
00061             Y = y;
00062         }

OpenTK.Vector2.Vector2 ( Vector2  v  ) 

Constructs a new Vector2 from the given Vector2.

Parameters:
v The Vector2 to copy components from.

Definition at line 69 of file Vector2.cs.

00070         {
00071             X = v.X;
00072             Y = v.Y;
00073         }

OpenTK.Vector2.Vector2 ( Vector3  v  ) 

Constructs a new Vector2 from the given Vector3.

Parameters:
v The Vector3 to copy components from. Z is discarded.

Definition at line 80 of file Vector2.cs.

00081         {
00082             X = v.X;
00083             Y = v.Y;
00084         }

OpenTK.Vector2.Vector2 ( Vector4  v  ) 

Constructs a new Vector2 from the given Vector4.

Parameters:
v The Vector4 to copy components from. Z and W are discarded.

Definition at line 91 of file Vector2.cs.

00092         {
00093             X = v.X;
00094             Y = v.Y;
00095         }


Member Function Documentation

static void OpenTK.Vector2.Add ( ref Vector2  a,
ref Vector2  b,
out Vector2  result 
) [static]

Adds two vectors.

Parameters:
a Left operand.
b Right operand.
result Result of operation.

Definition at line 480 of file Vector2.cs.

00481         {
00482             result = new Vector2(a.X + b.X, a.Y + b.Y);
00483         }

static Vector2 OpenTK.Vector2.Add ( Vector2  a,
Vector2  b 
) [static]

Adds two vectors.

Parameters:
a Left operand.
b Right operand.
Returns:
Result of operation.

Definition at line 468 of file Vector2.cs.

00469         {
00470             Add(ref a, ref b, out a);
00471             return a;
00472         }

void OpenTK.Vector2.Add ( ref Vector2  right  ) 

Add the Vector passed as parameter to this instance.

Parameters:
right Right operand. This parameter is only read from.

Definition at line 118 of file Vector2.cs.

00119         {
00120             this.X += right.X;
00121             this.Y += right.Y;
00122         }

void OpenTK.Vector2.Add ( Vector2  right  ) 

Add the Vector passed as parameter to this instance.

Parameters:
right Right operand. This parameter is only read from.

Definition at line 108 of file Vector2.cs.

00109         {
00110             this.X += right.X;
00111             this.Y += right.Y;
00112         }

static void OpenTK.Vector2.BaryCentric ( ref Vector2  a,
ref Vector2  b,
ref Vector2  c,
float  u,
float  v,
out Vector2  result 
) [static]

Interpolate 3 Vectors using Barycentric coordinates.

Parameters:
a First input Vector.
b Second input Vector.
c Third input Vector.
u First Barycentric Coordinate.
v Second Barycentric Coordinate.
result Output Vector. a when u=v=0, b when u=1,v=0, c when u=0,v=1, and a linear combination of a,b,c otherwise

Definition at line 871 of file Vector2.cs.

00872         {
00873             result = a; // copy
00874 
00875             Vector2 temp = b; // copy
00876             Subtract(ref temp, ref a, out temp);
00877             Multiply(ref temp, u, out temp);
00878             Add(ref result, ref temp, out result);
00879 
00880             temp = c; // copy
00881             Subtract(ref temp, ref a, out temp);
00882             Multiply(ref temp, v, out temp);
00883             Add(ref result, ref temp, out result);
00884         }

static Vector2 OpenTK.Vector2.BaryCentric ( Vector2  a,
Vector2  b,
Vector2  c,
float  u,
float  v 
) [static]

Interpolate 3 Vectors using Barycentric coordinates.

Parameters:
a First input Vector
b Second input Vector
c Third input Vector
u First Barycentric Coordinate
v Second Barycentric Coordinate
Returns:
a when u=v=0, b when u=1,v=0, c when u=0,v=1, and a linear combination of a,b,c otherwise

Definition at line 859 of file Vector2.cs.

00860         {
00861             return a + u * (b - a) + v * (c - a);
00862         }

static void OpenTK.Vector2.Clamp ( ref Vector2  vec,
ref Vector2  min,
ref Vector2  max,
out Vector2  result 
) [static]

Clamp a vector to the given minimum and maximum vectors.

Parameters:
vec Input vector
min Minimum vector
max Maximum vector
result The clamped vector

Definition at line 725 of file Vector2.cs.

00726         {
00727             result.X = vec.X < min.X ? min.X : vec.X > max.X ? max.X : vec.X;
00728             result.Y = vec.Y < min.Y ? min.Y : vec.Y > max.Y ? max.Y : vec.Y;
00729         }

static Vector2 OpenTK.Vector2.Clamp ( Vector2  vec,
Vector2  min,
Vector2  max 
) [static]

Clamp a vector to the given minimum and maximum vectors.

Parameters:
vec Input vector
min Minimum vector
max Maximum vector
Returns:
The clamped vector

Definition at line 711 of file Vector2.cs.

00712         {
00713             vec.X = vec.X < min.X ? min.X : vec.X > max.X ? max.X : vec.X;
00714             vec.Y = vec.Y < min.Y ? min.Y : vec.Y > max.Y ? max.Y : vec.Y;
00715             return vec;
00716         }

static void OpenTK.Vector2.ComponentMax ( ref Vector2  a,
ref Vector2  b,
out Vector2  result 
) [static]

Calculate the component-wise maximum of two vectors.

Parameters:
a First operand
b Second operand
result The component-wise maximum

Definition at line 664 of file Vector2.cs.

00665         {
00666             result.X = a.X > b.X ? a.X : b.X;
00667             result.Y = a.Y > b.Y ? a.Y : b.Y;
00668         }

static Vector2 OpenTK.Vector2.ComponentMax ( Vector2  a,
Vector2  b 
) [static]

Calculate the component-wise maximum of two vectors.

Parameters:
a First operand
b Second operand
Returns:
The component-wise maximum

Definition at line 651 of file Vector2.cs.

00652         {
00653             a.X = a.X > b.X ? a.X : b.X;
00654             a.Y = a.Y > b.Y ? a.Y : b.Y;
00655             return a;
00656         }

static void OpenTK.Vector2.ComponentMin ( ref Vector2  a,
ref Vector2  b,
out Vector2  result 
) [static]

Calculate the component-wise minimum of two vectors.

Parameters:
a First operand
b Second operand
result The component-wise minimum

Definition at line 635 of file Vector2.cs.

00636         {
00637             result.X = a.X < b.X ? a.X : b.X;
00638             result.Y = a.Y < b.Y ? a.Y : b.Y;
00639         }

static Vector2 OpenTK.Vector2.ComponentMin ( Vector2  a,
Vector2  b 
) [static]

Calculate the component-wise minimum of two vectors.

Parameters:
a First operand
b Second operand
Returns:
The component-wise minimum

Definition at line 622 of file Vector2.cs.

00623         {
00624             a.X = a.X < b.X ? a.X : b.X;
00625             a.Y = a.Y < b.Y ? a.Y : b.Y;
00626             return a;
00627         }

static void OpenTK.Vector2.Div ( ref Vector2  a,
float  f,
out Vector2  result 
) [static]

Divide a vector by a scalar.

Parameters:
a Vector operand
f Scalar operand
result Result of the division

Definition at line 449 of file Vector2.cs.

00450         {
00451             float mult = 1.0f / f;
00452             result.X = a.X * mult;
00453             result.Y = a.Y * mult;
00454         }

static Vector2 OpenTK.Vector2.Div ( Vector2  a,
float  f 
) [static]

Divide a vector by a scalar.

Parameters:
a Vector operand
f Scalar operand
Returns:
Result of the division

Definition at line 434 of file Vector2.cs.

00435         {
00436             float mult = 1.0f / f;
00437             a.X *= mult;
00438             a.Y *= mult;
00439             return a;
00440         }

void OpenTK.Vector2.Div ( float  f  ) 

Divide this instance by a scalar.

Parameters:
f Scalar operand.

Definition at line 167 of file Vector2.cs.

00168         {
00169             float mult = 1.0f / f;
00170             this.X *= mult;
00171             this.Y *= mult;
00172         }

static void OpenTK.Vector2.Divide ( ref Vector2  vector,
ref Vector2  scale,
out Vector2  result 
) [static]

Divide a vector by the components of a vector (scale).

Parameters:
vector Left operand.
scale Right operand.
result Result of the operation.

Definition at line 607 of file Vector2.cs.

00608         {
00609             result = new Vector2(vector.X / scale.X, vector.Y / scale.Y);
00610         }

static Vector2 OpenTK.Vector2.Divide ( Vector2  vector,
Vector2  scale 
) [static]

Divides a vector by the components of a vector (scale).

Parameters:
vector Left operand.
scale Right operand.
Returns:
Result of the operation.

Definition at line 595 of file Vector2.cs.

00596         {
00597             Divide(ref vector, ref scale, out vector);
00598             return vector;
00599         }

static void OpenTK.Vector2.Divide ( ref Vector2  vector,
float  scale,
out Vector2  result 
) [static]

Divides a vector by a scalar.

Parameters:
vector Left operand.
scale Right operand.
result Result of the operation.

Definition at line 584 of file Vector2.cs.

00585         {
00586             Multiply(ref vector, 1 / scale, out result);
00587         }

static Vector2 OpenTK.Vector2.Divide ( Vector2  vector,
float  scale 
) [static]

Divides a vector by a scalar.

Parameters:
vector Left operand.
scale Right operand.
Returns:
Result of the operation.

Definition at line 572 of file Vector2.cs.

00573         {
00574             Divide(ref vector, scale, out vector);
00575             return vector;
00576         }

static void OpenTK.Vector2.Dot ( ref Vector2  left,
ref Vector2  right,
out float  result 
) [static]

Calculate the dot (scalar) product of two vectors.

Parameters:
left First operand
right Second operand
result The dot product of the two inputs

Definition at line 810 of file Vector2.cs.

00811         {
00812             result = left.X * right.X + left.Y * right.Y;
00813         }

static float OpenTK.Vector2.Dot ( Vector2  left,
Vector2  right 
) [static]

Calculate the dot (scalar) product of two vectors.

Parameters:
left First operand
right Second operand
Returns:
The dot product of the two inputs

Definition at line 799 of file Vector2.cs.

00800         {
00801             return left.X * right.X + left.Y * right.Y;
00802         }

bool OpenTK.Vector2.Equals ( Vector2  other  ) 

Indicates whether the current vector is equal to another vector.

Parameters:
other A vector to compare with this vector.
Returns:
true if the current vector is equal to the vector parameter; otherwise, false.

Definition at line 1081 of file Vector2.cs.

01082         {
01083             return
01084                 X == other.X &&
01085                 Y == other.Y;
01086         }

override bool OpenTK.Vector2.Equals ( object  obj  ) 

Indicates whether this instance and a specified object are equal.

Parameters:
obj The object to compare to.
Returns:
True if the instances are equal; false otherwise.

Definition at line 1062 of file Vector2.cs.

01063         {
01064             if (!(obj is Vector2))
01065                 return false;
01066 
01067             return this.Equals((Vector2)obj);
01068         }

override int OpenTK.Vector2.GetHashCode (  ) 

Returns the hashcode for this instance.

Returns:
A System.Int32 containing the unique hashcode for this instance.

Definition at line 1048 of file Vector2.cs.

01049         {
01050             return X.GetHashCode() ^ Y.GetHashCode();
01051         }

static void OpenTK.Vector2.Lerp ( ref Vector2  a,
ref Vector2  b,
float  blend,
out Vector2  result 
) [static]

Returns a new Vector that is the linear blend of the 2 given Vectors.

Parameters:
a First input vector
b Second input vector
blend The blend factor. a when blend=0, b when blend=1.
result a when blend=0, b when blend=1, and a linear combination otherwise

Definition at line 840 of file Vector2.cs.

00841         {
00842             result.X = blend * (b.X - a.X) + a.X;
00843             result.Y = blend * (b.Y - a.Y) + a.Y;
00844         }

static Vector2 OpenTK.Vector2.Lerp ( Vector2  a,
Vector2  b,
float  blend 
) [static]

Returns a new Vector that is the linear blend of the 2 given Vectors.

Parameters:
a First input vector
b Second input vector
blend The blend factor. a when blend=0, b when blend=1.
Returns:
a when blend=0, b when blend=1, and a linear combination otherwise

Definition at line 826 of file Vector2.cs.

00827         {
00828             a.X = blend * (b.X - a.X) + a.X;
00829             a.Y = blend * (b.Y - a.Y) + a.Y;
00830             return a;
00831         }

static Vector2 OpenTK.Vector2.Max ( Vector2  left,
Vector2  right 
) [static]

Returns the Vector3 with the minimum magnitude.

Parameters:
left Left operand
right Right operand
Returns:
The minimum Vector3

Definition at line 695 of file Vector2.cs.

00696         {
00697             return left.LengthSquared >= right.LengthSquared ? left : right;
00698         }

static Vector2 OpenTK.Vector2.Min ( Vector2  left,
Vector2  right 
) [static]

Returns the Vector3 with the minimum magnitude.

Parameters:
left Left operand
right Right operand
Returns:
The minimum Vector3

Definition at line 680 of file Vector2.cs.

00681         {
00682             return left.LengthSquared < right.LengthSquared ? left : right;
00683         }

static void OpenTK.Vector2.Mult ( ref Vector2  a,
float  f,
out Vector2  result 
) [static]

Multiply a vector and a scalar.

Parameters:
a Vector operand
f Scalar operand
result Result of the multiplication

Definition at line 417 of file Vector2.cs.

00418         {
00419             result.X = a.X * f;
00420             result.Y = a.Y * f;
00421         }

static Vector2 OpenTK.Vector2.Mult ( Vector2  a,
float  f 
) [static]

Multiply a vector and a scalar.

Parameters:
a Vector operand
f Scalar operand
Returns:
Result of the multiplication

Definition at line 403 of file Vector2.cs.

00404         {
00405             a.X *= f;
00406             a.Y *= f;
00407             return a;
00408         }

void OpenTK.Vector2.Mult ( float  f  ) 

Multiply this instance by a scalar.

Parameters:
f Scalar operand.

Definition at line 154 of file Vector2.cs.

00155         {
00156             this.X *= f;
00157             this.Y *= f;
00158         }

static void OpenTK.Vector2.Multiply ( ref Vector2  vector,
ref Vector2  scale,
out Vector2  result 
) [static]

Multiplies a vector by the components of a vector (scale).

Parameters:
vector Left operand.
scale Right operand.
result Result of the operation.

Definition at line 557 of file Vector2.cs.

00558         {
00559             result = new Vector2(vector.X * scale.X, vector.Y * scale.Y);
00560         }

static Vector2 OpenTK.Vector2.Multiply ( Vector2  vector,
Vector2  scale 
) [static]

Multiplies a vector by the components a vector (scale).

Parameters:
vector Left operand.
scale Right operand.
Returns:
Result of the operation.

Definition at line 545 of file Vector2.cs.

00546         {
00547             Multiply(ref vector, ref scale, out vector);
00548             return vector;
00549         }

static void OpenTK.Vector2.Multiply ( ref Vector2  vector,
float  scale,
out Vector2  result 
) [static]

Multiplies a vector by a scalar.

Parameters:
vector Left operand.
scale Right operand.
result Result of the operation.

Definition at line 534 of file Vector2.cs.

00535         {
00536             result = new Vector2(vector.X * scale, vector.Y * scale);
00537         }

static Vector2 OpenTK.Vector2.Multiply ( Vector2  vector,
float  scale 
) [static]

Multiplies a vector by a scalar.

Parameters:
vector Left operand.
scale Right operand.
Returns:
Result of the operation.

Definition at line 522 of file Vector2.cs.

00523         {
00524             Multiply(ref vector, scale, out vector);
00525             return vector;
00526         }

static void OpenTK.Vector2.Normalize ( ref Vector2  vec,
out Vector2  result 
) [static]

Scale a vector to unit length.

Parameters:
vec The input vector
result The normalized vector

Definition at line 753 of file Vector2.cs.

00754         {
00755             float scale = 1.0f / vec.Length;
00756             result.X = vec.X * scale;
00757             result.Y = vec.Y * scale;
00758         }

static Vector2 OpenTK.Vector2.Normalize ( Vector2  vec  )  [static]

Scale a vector to unit length.

Parameters:
vec The input vector
Returns:
The normalized vector

Definition at line 740 of file Vector2.cs.

00741         {
00742             float scale = 1.0f / vec.Length;
00743             vec.X *= scale;
00744             vec.Y *= scale;
00745             return vec;
00746         }

void OpenTK.Vector2.Normalize (  ) 

Scales the Vector2 to unit length.

Definition at line 270 of file Vector2.cs.

00271         {
00272             float scale = 1.0f / this.Length;
00273             X *= scale;
00274             Y *= scale;
00275         }

static void OpenTK.Vector2.NormalizeFast ( ref Vector2  vec,
out Vector2  result 
) [static]

Scale a vector to approximately unit length.

Parameters:
vec The input vector
result The normalized vector

Definition at line 782 of file Vector2.cs.

00783         {
00784             float scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y);
00785             result.X = vec.X * scale;
00786             result.Y = vec.Y * scale;
00787         }

static Vector2 OpenTK.Vector2.NormalizeFast ( Vector2  vec  )  [static]

Scale a vector to approximately unit length.

Parameters:
vec The input vector
Returns:
The normalized vector

Definition at line 769 of file Vector2.cs.

00770         {
00771             float scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y);
00772             vec.X *= scale;
00773             vec.Y *= scale;
00774             return vec;
00775         }

void OpenTK.Vector2.NormalizeFast (  ) 

Scales the Vector2 to approximately unit length.

Definition at line 284 of file Vector2.cs.

00285         {
00286             float scale = MathHelper.InverseSqrtFast(X * X + Y * Y);
00287             X *= scale;
00288             Y *= scale;
00289         }

static bool OpenTK.Vector2.operator!= ( Vector2  left,
Vector2  right 
) [static]

Compares the specified instances for inequality.

Parameters:
left Left operand.
right Right operand.
Returns:
True if both instances are not equal; false otherwise.

Definition at line 1020 of file Vector2.cs.

01021         {
01022             return !left.Equals(right);
01023         }

static Vector2 OpenTK.Vector2.operator* ( float  scale,
Vector2  vec 
) [static]

Multiplies the specified instance by a scalar.

Parameters:
scale Left operand.
vec Right operand.
Returns:
Result of multiplication.

Definition at line 982 of file Vector2.cs.

00983         {
00984             vec.X *= scale;
00985             vec.Y *= scale;
00986             return vec;
00987         }

static Vector2 OpenTK.Vector2.operator* ( Vector2  vec,
float  scale 
) [static]

Multiplies the specified instance by a scalar.

Parameters:
vec Left operand.
scale Right operand.
Returns:
Result of multiplication.

Definition at line 969 of file Vector2.cs.

00970         {
00971             vec.X *= scale;
00972             vec.Y *= scale;
00973             return vec;
00974         }

static Vector2 OpenTK.Vector2.operator+ ( Vector2  left,
Vector2  right 
) [static]

Adds the specified instances.

Parameters:
left Left operand.
right Right operand.
Returns:
Result of addition.

Definition at line 931 of file Vector2.cs.

00932         {
00933             left.X += right.X;
00934             left.Y += right.Y;
00935             return left;
00936         }

static Vector2 OpenTK.Vector2.operator- ( Vector2  vec  )  [static]

Negates the specified instance.

Parameters:
vec Operand.
Returns:
Result of negation.

Definition at line 956 of file Vector2.cs.

00957         {
00958             vec.X = -vec.X;
00959             vec.Y = -vec.Y;
00960             return vec;
00961         }

static Vector2 OpenTK.Vector2.operator- ( Vector2  left,
Vector2  right 
) [static]

Subtracts the specified instances.

Parameters:
left Left operand.
right Right operand.
Returns:
Result of subtraction.

Definition at line 944 of file Vector2.cs.

00945         {
00946             left.X -= right.X;
00947             left.Y -= right.Y;
00948             return left;
00949         }

static Vector2 OpenTK.Vector2.operator/ ( Vector2  vec,
float  scale 
) [static]

Divides the specified instance by a scalar.

Parameters:
vec Left operand
scale Right operand
Returns:
Result of the division.

Definition at line 995 of file Vector2.cs.

00996         {
00997             float mult = 1.0f / scale;
00998             vec.X *= mult;
00999             vec.Y *= mult;
01000             return vec;
01001         }

static bool OpenTK.Vector2.operator== ( Vector2  left,
Vector2  right 
) [static]

Compares the specified instances for equality.

Parameters:
left Left operand.
right Right operand.
Returns:
True if both instances are equal; false otherwise.

Definition at line 1009 of file Vector2.cs.

01010         {
01011             return left.Equals(right);
01012         }

void OpenTK.Vector2.Scale ( ref Vector2  scale  ) 

Scales this instance by the given parameter.

Parameters:
scale The scaling of the individual components.

Definition at line 320 of file Vector2.cs.

00321         {
00322             this.X *= scale.X;
00323             this.Y *= scale.Y;
00324         }

void OpenTK.Vector2.Scale ( Vector2  scale  ) 

Scales this instance by the given parameter.

Parameters:
scale The scaling of the individual components.

Definition at line 310 of file Vector2.cs.

00311         {
00312             this.X *= scale.X;
00313             this.Y *= scale.Y;
00314         }

void OpenTK.Vector2.Scale ( float  sx,
float  sy 
)

Scales the current Vector2 by the given amounts.

Parameters:
sx The scale of the X component.
sy The scale of the Y component.

Definition at line 301 of file Vector2.cs.

00302         {
00303             this.X = X * sx;
00304             this.Y = Y * sy;
00305         }

static void OpenTK.Vector2.Sub ( ref Vector2  a,
ref Vector2  b,
out Vector2  result 
) [static]

Subtract one Vector from another.

Parameters:
a First operand
b Second operand
result Result of subtraction

Definition at line 386 of file Vector2.cs.

00387         {
00388             result.X = a.X - b.X;
00389             result.Y = a.Y - b.Y;
00390         }

static Vector2 OpenTK.Vector2.Sub ( Vector2  a,
Vector2  b 
) [static]

Subtract one Vector from another.

Parameters:
a First operand
b Second operand
Returns:
Result of subtraction

Definition at line 372 of file Vector2.cs.

00373         {
00374             a.X -= b.X;
00375             a.Y -= b.Y;
00376             return a;
00377         }

void OpenTK.Vector2.Sub ( ref Vector2  right  ) 

Subtract the Vector passed as parameter from this instance.

Parameters:
right Right operand. This parameter is only read from.

Definition at line 141 of file Vector2.cs.

00142         {
00143             this.X -= right.X;
00144             this.Y -= right.Y;
00145         }

void OpenTK.Vector2.Sub ( Vector2  right  ) 

Subtract the Vector passed as parameter from this instance.

Parameters:
right Right operand. This parameter is only read from.

Definition at line 131 of file Vector2.cs.

00132         {
00133             this.X -= right.X;
00134             this.Y -= right.Y;
00135         }

static void OpenTK.Vector2.Subtract ( ref Vector2  a,
ref Vector2  b,
out Vector2  result 
) [static]

Subtract one Vector from another.

Parameters:
a First operand
b Second operand
result Result of subtraction

Definition at line 507 of file Vector2.cs.

00508         {
00509             result = new Vector2(a.X - b.X, a.Y - b.Y);
00510         }

static Vector2 OpenTK.Vector2.Subtract ( Vector2  a,
Vector2  b 
) [static]

Subtract one Vector from another.

Parameters:
a First operand
b Second operand
Returns:
Result of subtraction

Definition at line 495 of file Vector2.cs.

00496         {
00497             Subtract(ref a, ref b, out a);
00498             return a;
00499         }

override string OpenTK.Vector2.ToString (  ) 

Returns a System.String that represents the current Vector2.

Returns:

Definition at line 1035 of file Vector2.cs.

01036         {
01037             return String.Format("({0}, {1})", X, Y);
01038         }

static void OpenTK.Vector2.Transform ( ref Vector2  vec,
ref Quaternion  quat,
out Vector2  result 
) [static]

Transforms a vector by a quaternion rotation.

Parameters:
vec The vector to transform.
quat The quaternion to rotate the vector by.
result The result of the operation.

Definition at line 909 of file Vector2.cs.

00910         {
00911             Quaternion v = new Quaternion(vec.X, vec.Y, 0, 0), i, t;
00912             Quaternion.Invert(ref quat, out i);
00913             Quaternion.Multiply(ref quat, ref v, out t);
00914             Quaternion.Multiply(ref t, ref i, out v);
00915 
00916             result = new Vector2(v.X, v.Y);
00917         }

static Vector2 OpenTK.Vector2.Transform ( Vector2  vec,
Quaternion  quat 
) [static]

Transforms a vector by a quaternion rotation.

Parameters:
vec The vector to transform.
quat The quaternion to rotate the vector by.
Returns:
The result of the operation.

Definition at line 896 of file Vector2.cs.

00897         {
00898             Vector2 result;
00899             Transform(ref vec, ref quat, out result);
00900             return result;
00901         }


Member Data Documentation

readonly Vector2 OpenTK.Vector2.One = new Vector2(1, 1) [static]

Defines an instance with all components set to 1.

Definition at line 352 of file Vector2.cs.

readonly int OpenTK.Vector2.SizeInBytes = Marshal.SizeOf(new Vector2()) [static]

Defines the size of the Vector2 struct in bytes.

Definition at line 357 of file Vector2.cs.

readonly Vector2 OpenTK.Vector2.UnitX = new Vector2(1, 0) [static]

Defines a unit-length Vector2 that points towards the X-axis.

Definition at line 337 of file Vector2.cs.

readonly Vector2 OpenTK.Vector2.UnitY = new Vector2(0, 1) [static]

Defines a unit-length Vector2 that points towards the Y-axis.

Definition at line 342 of file Vector2.cs.

The X component of the Vector2.

Definition at line 42 of file Vector2.cs.

The Y component of the Vector2.

Definition at line 47 of file Vector2.cs.

readonly Vector2 OpenTK.Vector2.Zero = new Vector2(0, 0) [static]

Defines a zero-length Vector2.

Definition at line 347 of file Vector2.cs.


Property Documentation

float OpenTK.Vector2.Length [get]

Gets the length (magnitude) of the vector.

LengthFast

See also:
LengthSquared

Definition at line 184 of file Vector2.cs.

float OpenTK.Vector2.LengthFast [get]

Gets an approximation of the vector length (magnitude).

This property uses an approximation of the square root function to calculate vector magnitude, with an upper error bound of 0.001.

Length

See also:
LengthSquared

Definition at line 205 of file Vector2.cs.

float OpenTK.Vector2.LengthSquared [get]

Gets the square of the vector length (magnitude).

This property avoids the costly square root operation required by the Length property. This makes it more suitable for comparisons.

Length

See also:
LengthFast

Definition at line 226 of file Vector2.cs.

Vector2 OpenTK.Vector2.PerpendicularLeft [get]

Gets the perpendicular vector on the left side of this vector.

Definition at line 256 of file Vector2.cs.

Vector2 OpenTK.Vector2.PerpendicularRight [get]

Gets the perpendicular vector on the right side of this vector.

Definition at line 241 of file Vector2.cs.

 All Classes Functions Variables Enumerations Properties Events

Generated on Tue Mar 9 14:59:16 2010 for The Open Toolkit library by  doxygen 1.6.1