OpenTK.Vector4 Struct Reference

Represents a 4D vector using four single-precision floating-point numbers. More...

List of all members.

Public Member Functions

 Vector4 (float x, float y, float z, float w)
 Constructs a new Vector4.
 Vector4 (Vector2 v)
 Constructs a new Vector4 from the given Vector2.
 Vector4 (Vector3 v)
 Constructs a new Vector4 from the given Vector3.
 Vector4 (Vector3 v, float w)
 Constructs a new Vector4 from the specified Vector3 and w component.
 Vector4 (Vector4 v)
 Constructs a new Vector4 from the given Vector4.
void Add (Vector4 right)
 Add the Vector passed as parameter to this instance.
void Add (ref Vector4 right)
 Add the Vector passed as parameter to this instance.
void Sub (Vector4 right)
 Subtract the Vector passed as parameter from this instance.
void Sub (ref Vector4 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 Vector4 to unit length.
void NormalizeFast ()
 Scales the Vector4 to approximately unit length.
void Scale (float sx, float sy, float sz, float sw)
 Scales the current Vector4 by the given amounts.
void Scale (Vector4 scale)
 Scales this instance by the given parameter.
void Scale (ref Vector4 scale)
 Scales this instance by the given parameter.
override string ToString ()
 Returns a System.String that represents the current Vector4.
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 (Vector4 other)
 Indicates whether the current vector is equal to another vector.

Static Public Member Functions

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

Public Attributes

float X
 The X component of the Vector4.
float Y
 The Y component of the Vector4.
float Z
 The Z component of the Vector4.
float W
 The W component of the Vector4.

Static Public Attributes

static Vector4 UnitX = new Vector4(1, 0, 0, 0)
 Defines a unit-length Vector4 that points towards the X-axis.
static Vector4 UnitY = new Vector4(0, 1, 0, 0)
 Defines a unit-length Vector4 that points towards the Y-axis.
static Vector4 UnitZ = new Vector4(0, 0, 1, 0)
 Defines a unit-length Vector4 that points towards the Z-axis.
static Vector4 UnitW = new Vector4(0, 0, 0, 1)
 Defines a unit-length Vector4 that points towards the W-axis.
static Vector4 Zero = new Vector4(0, 0, 0, 0)
 Defines a zero-length Vector4.
static readonly Vector4 One = new Vector4(1, 1, 1, 1)
 Defines an instance with all components set to 1.
static readonly int SizeInBytes = Marshal.SizeOf(new Vector4())
 Defines the size of the Vector4 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 Xy [get, set]
 Gets or sets an OpenTK.Vector2 with the X and Y components of this instance.
Vector3 Xyz [get, set]
 Gets or sets an OpenTK.Vector3 with the X, Y and Z components of this instance.

Detailed Description

Represents a 4D vector using four single-precision floating-point numbers.

The Vector4 structure is suitable for interoperation with unmanaged code requiring four consecutive floats.

Definition at line 36 of file Vector4.cs.


Constructor & Destructor Documentation

OpenTK.Vector4.Vector4 ( float  x,
float  y,
float  z,
float  w 
)

Constructs a new Vector4.

Parameters:
x The x component of the Vector4.
y The y component of the Vector4.
z The z component of the Vector4.
w The w component of the Vector4.

Definition at line 106 of file Vector4.cs.

00107         {
00108             X = x;
00109             Y = y;
00110             Z = z;
00111             W = w;
00112         }

OpenTK.Vector4.Vector4 ( Vector2  v  ) 

Constructs a new Vector4 from the given Vector2.

Parameters:
v The Vector2 to copy components from.

Definition at line 118 of file Vector4.cs.

00119         {
00120             X = v.X;
00121             Y = v.Y;
00122             Z = 0.0f;
00123             W = 0.0f;
00124         }

OpenTK.Vector4.Vector4 ( Vector3  v  ) 

Constructs a new Vector4 from the given Vector3.

Parameters:
v The Vector3 to copy components from.

Definition at line 130 of file Vector4.cs.

00131         {
00132             X = v.X;
00133             Y = v.Y;
00134             Z = v.Z;
00135             W = 0.0f;
00136         }

OpenTK.Vector4.Vector4 ( Vector3  v,
float  w 
)

Constructs a new Vector4 from the specified Vector3 and w component.

Parameters:
v The Vector3 to copy components from.
w The w component of the new Vector4.

Definition at line 143 of file Vector4.cs.

00144         {
00145             X = v.X;
00146             Y = v.Y;
00147             Z = v.Z;
00148             W = w;
00149         }

OpenTK.Vector4.Vector4 ( Vector4  v  ) 

Constructs a new Vector4 from the given Vector4.

Parameters:
v The Vector4 to copy components from.

Definition at line 155 of file Vector4.cs.

00156         {
00157             X = v.X;
00158             Y = v.Y;
00159             Z = v.Z;
00160             W = v.W;
00161         }


Member Function Documentation

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

Adds two vectors.

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

Definition at line 517 of file Vector4.cs.

00518         {
00519             result = new Vector4(a.X + b.X, a.Y + b.Y, a.Z + b.Z, a.W + b.W);
00520         }

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

Adds two vectors.

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

Definition at line 505 of file Vector4.cs.

00506         {
00507             Add(ref a, ref b, out a);
00508             return a;
00509         }

void OpenTK.Vector4.Add ( ref Vector4  right  ) 

Add the Vector passed as parameter to this instance.

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

Definition at line 186 of file Vector4.cs.

00187         {
00188             this.X += right.X;
00189             this.Y += right.Y;
00190             this.Z += right.Z;
00191             this.W += right.W;
00192         }

void OpenTK.Vector4.Add ( Vector4  right  ) 

Add the Vector passed as parameter to this instance.

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

Definition at line 174 of file Vector4.cs.

00175         {
00176             this.X += right.X;
00177             this.Y += right.Y;
00178             this.Z += right.Z;
00179             this.W += right.W;
00180         }

static void OpenTK.Vector4.BaryCentric ( ref Vector4  a,
ref Vector4  b,
ref Vector4  c,
float  u,
float  v,
out Vector4  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 902 of file Vector4.cs.

00903         {
00904             result = a; // copy
00905 
00906             Vector4 temp = b; // copy
00907             Subtract(ref temp, ref a, out temp);
00908             Multiply(ref temp, u, out temp);
00909             Add(ref result, ref temp, out result);
00910 
00911             temp = c; // copy
00912             Subtract(ref temp, ref a, out temp);
00913             Multiply(ref temp, v, out temp);
00914             Add(ref result, ref temp, out result);
00915         }

static Vector4 OpenTK.Vector4.BaryCentric ( Vector4  a,
Vector4  b,
Vector4  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 890 of file Vector4.cs.

00891         {
00892             return a + u * (b - a) + v * (c - a);
00893         }

static void OpenTK.Vector4.Clamp ( ref Vector4  vec,
ref Vector4  min,
ref Vector4  max,
out Vector4  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 742 of file Vector4.cs.

00743         {
00744             result.X = vec.X < min.X ? min.X : vec.X > max.X ? max.X : vec.X;
00745             result.Y = vec.Y < min.Y ? min.Y : vec.Y > max.Y ? max.Y : vec.Y;
00746             result.Z = vec.X < min.Z ? min.Z : vec.Z > max.Z ? max.Z : vec.Z;
00747             result.W = vec.Y < min.W ? min.W : vec.W > max.W ? max.W : vec.W;
00748         }

static Vector4 OpenTK.Vector4.Clamp ( Vector4  vec,
Vector4  min,
Vector4  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 726 of file Vector4.cs.

00727         {
00728             vec.X = vec.X < min.X ? min.X : vec.X > max.X ? max.X : vec.X;
00729             vec.Y = vec.Y < min.Y ? min.Y : vec.Y > max.Y ? max.Y : vec.Y;
00730             vec.Z = vec.X < min.Z ? min.Z : vec.Z > max.Z ? max.Z : vec.Z;
00731             vec.W = vec.Y < min.W ? min.W : vec.W > max.W ? max.W : vec.W;
00732             return vec;
00733         }

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

Divide a vector by a scalar.

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

Definition at line 484 of file Vector4.cs.

00485         {
00486             float mult = 1.0f / f;
00487             result.X = a.X * mult;
00488             result.Y = a.Y * mult;
00489             result.Z = a.Z * mult;
00490             result.W = a.W * mult;
00491         }

static Vector4 OpenTK.Vector4.Div ( Vector4  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 468 of file Vector4.cs.

00469         {
00470             float mult = 1.0f / f;
00471             a.X *= mult;
00472             a.Y *= mult;
00473             a.Z *= mult;
00474             a.W *= mult;
00475             return a;
00476         }

void OpenTK.Vector4.Div ( float  f  ) 

Divide this instance by a scalar.

Parameters:
f Scalar operand.

Definition at line 243 of file Vector4.cs.

00244         {
00245             float mult = 1.0f / f;
00246             this.X *= mult;
00247             this.Y *= mult;
00248             this.Z *= mult;
00249             this.W *= mult;
00250         }

static void OpenTK.Vector4.Divide ( ref Vector4  vector,
ref Vector4  scale,
out Vector4  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 644 of file Vector4.cs.

00645         {
00646             result = new Vector4(vector.X / scale.X, vector.Y / scale.Y, vector.Z / scale.Z, vector.W / scale.W);
00647         }

static Vector4 OpenTK.Vector4.Divide ( Vector4  vector,
Vector4  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 632 of file Vector4.cs.

00633         {
00634             Divide(ref vector, ref scale, out vector);
00635             return vector;
00636         }

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

Divides a vector by a scalar.

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

Definition at line 621 of file Vector4.cs.

00622         {
00623             Multiply(ref vector, 1 / scale, out result);
00624         }

static Vector4 OpenTK.Vector4.Divide ( Vector4  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 609 of file Vector4.cs.

00610         {
00611             Divide(ref vector, scale, out vector);
00612             return vector;
00613         }

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

Calculate the dot product of two vectors.

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

Definition at line 837 of file Vector4.cs.

00838         {
00839             result = left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W;
00840         }

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

Calculate the dot product of two vectors.

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

Definition at line 826 of file Vector4.cs.

00827         {
00828             return left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W;
00829         }

bool OpenTK.Vector4.Equals ( Vector4  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 1188 of file Vector4.cs.

01189         {
01190             return
01191                 X == other.X &&
01192                 Y == other.Y &&
01193                 Z == other.Z &&
01194                 W == other.W;
01195         }

override bool OpenTK.Vector4.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 1169 of file Vector4.cs.

01170         {
01171             if (!(obj is Vector4))
01172                 return false;
01173 
01174             return this.Equals((Vector4)obj);
01175         }

override int OpenTK.Vector4.GetHashCode (  ) 

Returns the hashcode for this instance.

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

Definition at line 1155 of file Vector4.cs.

01156         {
01157             return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode() ^ W.GetHashCode();
01158         }

static void OpenTK.Vector4.Lerp ( ref Vector4  a,
ref Vector4  b,
float  blend,
out Vector4  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 869 of file Vector4.cs.

00870         {
00871             result.X = blend * (b.X - a.X) + a.X;
00872             result.Y = blend * (b.Y - a.Y) + a.Y;
00873             result.Z = blend * (b.Z - a.Z) + a.Z;
00874             result.W = blend * (b.W - a.W) + a.W;
00875         }

static Vector4 OpenTK.Vector4.Lerp ( Vector4  a,
Vector4  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 853 of file Vector4.cs.

00854         {
00855             a.X = blend * (b.X - a.X) + a.X;
00856             a.Y = blend * (b.Y - a.Y) + a.Y;
00857             a.Z = blend * (b.Z - a.Z) + a.Z;
00858             a.W = blend * (b.W - a.W) + a.W;
00859             return a;
00860         }

static void OpenTK.Vector4.Max ( ref Vector4  a,
ref Vector4  b,
out Vector4  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 707 of file Vector4.cs.

00708         {
00709             result.X = a.X > b.X ? a.X : b.X;
00710             result.Y = a.Y > b.Y ? a.Y : b.Y;
00711             result.Z = a.Z > b.Z ? a.Z : b.Z;
00712             result.W = a.W > b.W ? a.W : b.W;
00713         }

static Vector4 OpenTK.Vector4.Max ( Vector4  a,
Vector4  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 692 of file Vector4.cs.

00693         {
00694             a.X = a.X > b.X ? a.X : b.X;
00695             a.Y = a.Y > b.Y ? a.Y : b.Y;
00696             a.Z = a.Z > b.Z ? a.Z : b.Z;
00697             a.W = a.W > b.W ? a.W : b.W;
00698             return a;
00699         }

static void OpenTK.Vector4.Min ( ref Vector4  a,
ref Vector4  b,
out Vector4  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 674 of file Vector4.cs.

00675         {
00676             result.X = a.X < b.X ? a.X : b.X;
00677             result.Y = a.Y < b.Y ? a.Y : b.Y;
00678             result.Z = a.Z < b.Z ? a.Z : b.Z;
00679             result.W = a.W < b.W ? a.W : b.W;
00680         }

static Vector4 OpenTK.Vector4.Min ( Vector4  a,
Vector4  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 659 of file Vector4.cs.

00660         {
00661             a.X = a.X < b.X ? a.X : b.X;
00662             a.Y = a.Y < b.Y ? a.Y : b.Y;
00663             a.Z = a.Z < b.Z ? a.Z : b.Z;
00664             a.W = a.W < b.W ? a.W : b.W;
00665             return a;
00666         }

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

Multiply a vector and a scalar.

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

Definition at line 450 of file Vector4.cs.

00451         {
00452             result.X = a.X * f;
00453             result.Y = a.Y * f;
00454             result.Z = a.Z * f;
00455             result.W = a.W * f;
00456         }

static Vector4 OpenTK.Vector4.Mult ( Vector4  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 435 of file Vector4.cs.

00436         {
00437             a.X *= f;
00438             a.Y *= f;
00439             a.Z *= f;
00440             a.W *= f;
00441             return a;
00442         }

void OpenTK.Vector4.Mult ( float  f  ) 

Multiply this instance by a scalar.

Parameters:
f Scalar operand.

Definition at line 228 of file Vector4.cs.

00229         {
00230             this.X *= f;
00231             this.Y *= f;
00232             this.Z *= f;
00233             this.W *= f;
00234         }

static void OpenTK.Vector4.Multiply ( ref Vector4  vector,
ref Vector4  scale,
out Vector4  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 594 of file Vector4.cs.

00595         {
00596             result = new Vector4(vector.X * scale.X, vector.Y * scale.Y, vector.Z * scale.Z, vector.W * scale.W);
00597         }

static Vector4 OpenTK.Vector4.Multiply ( Vector4  vector,
Vector4  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 582 of file Vector4.cs.

00583         {
00584             Multiply(ref vector, ref scale, out vector);
00585             return vector;
00586         }

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

Multiplies a vector by a scalar.

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

Definition at line 571 of file Vector4.cs.

00572         {
00573             result = new Vector4(vector.X * scale, vector.Y * scale, vector.Z * scale, vector.W * scale);
00574         }

static Vector4 OpenTK.Vector4.Multiply ( Vector4  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 559 of file Vector4.cs.

00560         {
00561             Multiply(ref vector, scale, out vector);
00562             return vector;
00563         }

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

Scale a vector to unit length.

Parameters:
vec The input vector
result The normalized vector

Definition at line 774 of file Vector4.cs.

00775         {
00776             float scale = 1.0f / vec.Length;
00777             result.X = vec.X * scale;
00778             result.Y = vec.Y * scale;
00779             result.Z = vec.Z * scale;
00780             result.W = vec.W * scale;
00781         }

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

Scale a vector to unit length.

Parameters:
vec The input vector
Returns:
The normalized vector

Definition at line 759 of file Vector4.cs.

00760         {
00761             float scale = 1.0f / vec.Length;
00762             vec.X *= scale;
00763             vec.Y *= scale;
00764             vec.Z *= scale;
00765             vec.W *= scale;
00766             return vec;
00767         }

void OpenTK.Vector4.Normalize (  ) 

Scales the Vector4 to unit length.

Definition at line 318 of file Vector4.cs.

00319         {
00320             float scale = 1.0f / this.Length;
00321             X *= scale;
00322             Y *= scale;
00323             Z *= scale;
00324             W *= scale;
00325         }

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

Scale a vector to approximately unit length.

Parameters:
vec The input vector
result The normalized vector

Definition at line 807 of file Vector4.cs.

00808         {
00809             float scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z + vec.W * vec.W);
00810             result.X = vec.X * scale;
00811             result.Y = vec.Y * scale;
00812             result.Z = vec.Z * scale;
00813             result.W = vec.W * scale;
00814         }

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

Scale a vector to approximately unit length.

Parameters:
vec The input vector
Returns:
The normalized vector

Definition at line 792 of file Vector4.cs.

00793         {
00794             float scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z + vec.W * vec.W);
00795             vec.X *= scale;
00796             vec.Y *= scale;
00797             vec.Z *= scale;
00798             vec.W *= scale;
00799             return vec;
00800         }

void OpenTK.Vector4.NormalizeFast (  ) 

Scales the Vector4 to approximately unit length.

Definition at line 334 of file Vector4.cs.

00335         {
00336             float scale = MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z + W * W);
00337             X *= scale;
00338             Y *= scale;
00339             Z *= scale;
00340             W *= scale;
00341         }

unsafe static OpenTK.Vector4.operator float * ( Vector4  v  )  [explicit, static]

Returns a pointer to the first element of the specified instance.

Parameters:
v The instance.
Returns:
A pointer to the first element of v.

Definition at line 1114 of file Vector4.cs.

01115         {
01116             return &v.X;
01117         }

static OpenTK.Vector4.operator IntPtr ( Vector4  v  )  [explicit, static]

Returns a pointer to the first element of the specified instance.

Parameters:
v The instance.
Returns:
A pointer to the first element of v.

Definition at line 1124 of file Vector4.cs.

01125         {
01126             unsafe
01127             {
01128                 return (IntPtr)(&v.X);
01129             }
01130         }

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

Compares two instances for inequality.

Parameters:
left The first instance.
right The second instance.
Returns:
True, if left does not equa lright; false otherwise.

Definition at line 1103 of file Vector4.cs.

01104         {
01105             return !left.Equals(right);
01106         }

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

Multiplies an instance by a scalar.

Parameters:
scale The scalar.
vec The instance.
Returns:
The result of the calculation.

Definition at line 1061 of file Vector4.cs.

01062         {
01063             vec.X *= scale;
01064             vec.Y *= scale;
01065             vec.Z *= scale;
01066             vec.W *= scale;
01067             return vec;
01068         }

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

Multiplies an instance by a scalar.

Parameters:
vec The instance.
scale The scalar.
Returns:
The result of the calculation.

Definition at line 1046 of file Vector4.cs.

01047         {
01048             vec.X *= scale;
01049             vec.Y *= scale;
01050             vec.Z *= scale;
01051             vec.W *= scale;
01052             return vec;
01053         }

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

Adds two instances.

Parameters:
left The first instance.
right The second instance.
Returns:
The result of the calculation.

Definition at line 1002 of file Vector4.cs.

01003         {
01004             left.X += right.X;
01005             left.Y += right.Y;
01006             left.Z += right.Z;
01007             left.W += right.W;
01008             return left;
01009         }

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

Negates an instance.

Parameters:
vec The instance.
Returns:
The result of the calculation.

Definition at line 1031 of file Vector4.cs.

01032         {
01033             vec.X = -vec.X;
01034             vec.Y = -vec.Y;
01035             vec.Z = -vec.Z;
01036             vec.W = -vec.W;
01037             return vec;
01038         }

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

Subtracts two instances.

Parameters:
left The first instance.
right The second instance.
Returns:
The result of the calculation.

Definition at line 1017 of file Vector4.cs.

01018         {
01019             left.X -= right.X;
01020             left.Y -= right.Y;
01021             left.Z -= right.Z;
01022             left.W -= right.W;
01023             return left;
01024         }

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

Divides an instance by a scalar.

Parameters:
vec The instance.
scale The scalar.
Returns:
The result of the calculation.

Definition at line 1076 of file Vector4.cs.

01077         {
01078             float mult = 1.0f / scale;
01079             vec.X *= mult;
01080             vec.Y *= mult;
01081             vec.Z *= mult;
01082             vec.W *= mult;
01083             return vec;
01084         }

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

Compares two instances for equality.

Parameters:
left The first instance.
right The second instance.
Returns:
True, if left equals right; false otherwise.

Definition at line 1092 of file Vector4.cs.

01093         {
01094             return left.Equals(right);
01095         }

void OpenTK.Vector4.Scale ( ref Vector4  scale  ) 

Scales this instance by the given parameter.

Parameters:
scale The scaling of the individual components.

Definition at line 378 of file Vector4.cs.

00379         {
00380             this.X *= scale.X;
00381             this.Y *= scale.Y;
00382             this.Z *= scale.Z;
00383             this.W *= scale.W;
00384         }

void OpenTK.Vector4.Scale ( Vector4  scale  ) 

Scales this instance by the given parameter.

Parameters:
scale The scaling of the individual components.

Definition at line 366 of file Vector4.cs.

00367         {
00368             this.X *= scale.X;
00369             this.Y *= scale.Y;
00370             this.Z *= scale.Z;
00371             this.W *= scale.W;
00372         }

void OpenTK.Vector4.Scale ( float  sx,
float  sy,
float  sz,
float  sw 
)

Scales the current Vector4 by the given amounts.

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

Definition at line 355 of file Vector4.cs.

00356         {
00357             this.X = X * sx;
00358             this.Y = Y * sy;
00359             this.Z = Z * sz;
00360             this.W = W * sw;
00361         }

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

Subtract one Vector from another.

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

Definition at line 417 of file Vector4.cs.

00418         {
00419             result.X = a.X - b.X;
00420             result.Y = a.Y - b.Y;
00421             result.Z = a.Z - b.Z;
00422             result.W = a.W - b.W;
00423         }

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

Subtract one Vector from another.

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

Definition at line 402 of file Vector4.cs.

00403         {
00404             a.X -= b.X;
00405             a.Y -= b.Y;
00406             a.Z -= b.Z;
00407             a.W -= b.W;
00408             return a;
00409         }

void OpenTK.Vector4.Sub ( ref Vector4  right  ) 

Subtract the Vector passed as parameter from this instance.

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

Definition at line 213 of file Vector4.cs.

00214         {
00215             this.X -= right.X;
00216             this.Y -= right.Y;
00217             this.Z -= right.Z;
00218             this.W -= right.W;
00219         }

void OpenTK.Vector4.Sub ( Vector4  right  ) 

Subtract the Vector passed as parameter from this instance.

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

Definition at line 201 of file Vector4.cs.

00202         {
00203             this.X -= right.X;
00204             this.Y -= right.Y;
00205             this.Z -= right.Z;
00206             this.W -= right.W;
00207         }

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

Subtract one Vector from another.

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

Definition at line 544 of file Vector4.cs.

00545         {
00546             result = new Vector4(a.X - b.X, a.Y - b.Y, a.Z - b.Z, a.W - b.W);
00547         }

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

Subtract one Vector from another.

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

Definition at line 532 of file Vector4.cs.

00533         {
00534             Subtract(ref a, ref b, out a);
00535             return a;
00536         }

override string OpenTK.Vector4.ToString (  ) 

Returns a System.String that represents the current Vector4.

Returns:

Definition at line 1142 of file Vector4.cs.

01143         {
01144             return String.Format("({0}, {1}, {2}, {3})", X, Y, Z, W);
01145         }

static void OpenTK.Vector4.Transform ( ref Vector4  vec,
ref Quaternion  quat,
out Vector4  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 964 of file Vector4.cs.

00965         {
00966             Quaternion v = new Quaternion(vec.X, vec.Y, vec.Z, vec.W), i, t;
00967             Quaternion.Invert(ref quat, out i);
00968             Quaternion.Multiply(ref quat, ref v, out t);
00969             Quaternion.Multiply(ref t, ref i, out v);
00970 
00971             result = new Vector4(v.X, v.Y, v.Z, v.W);
00972         }

static Vector4 OpenTK.Vector4.Transform ( Vector4  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 951 of file Vector4.cs.

00952         {
00953             Vector4 result;
00954             Transform(ref vec, ref quat, out result);
00955             return result;
00956         }

static void OpenTK.Vector4.Transform ( ref Vector4  vec,
ref Matrix4  mat,
out Vector4  result 
) [static]

Transform a Vector by the given Matrix.

Parameters:
vec The vector to transform
mat The desired transformation
result The transformed vector

Definition at line 936 of file Vector4.cs.

00937         {
00938             result = new Vector4(
00939                 vec.X * mat.Row0.X + vec.Y * mat.Row1.X + vec.Z * mat.Row2.X + vec.W * mat.Row3.X,
00940                 vec.X * mat.Row0.Y + vec.Y * mat.Row1.Y + vec.Z * mat.Row2.Y + vec.W * mat.Row3.Y,
00941                 vec.X * mat.Row0.Z + vec.Y * mat.Row1.Z + vec.Z * mat.Row2.Z + vec.W * mat.Row3.Z,
00942                 vec.X * mat.Row0.W + vec.Y * mat.Row1.W + vec.Z * mat.Row2.W + vec.W * mat.Row3.W);
00943         }

static Vector4 OpenTK.Vector4.Transform ( Vector4  vec,
Matrix4  mat 
) [static]

Transform a Vector by the given Matrix.

Parameters:
vec The vector to transform
mat The desired transformation
Returns:
The transformed vector

Definition at line 925 of file Vector4.cs.

00926         {
00927             Vector4 result;
00928             Transform(ref vec, ref mat, out result);
00929             return result;
00930         }


Member Data Documentation

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

Defines an instance with all components set to 1.

Definition at line 88 of file Vector4.cs.

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

Defines the size of the Vector4 struct in bytes.

Definition at line 93 of file Vector4.cs.

Vector4 OpenTK.Vector4.UnitW = new Vector4(0, 0, 0, 1) [static]

Defines a unit-length Vector4 that points towards the W-axis.

Definition at line 78 of file Vector4.cs.

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

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

Definition at line 63 of file Vector4.cs.

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

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

Definition at line 68 of file Vector4.cs.

Vector4 OpenTK.Vector4.UnitZ = new Vector4(0, 0, 1, 0) [static]

Defines a unit-length Vector4 that points towards the Z-axis.

Definition at line 73 of file Vector4.cs.

The W component of the Vector4.

Definition at line 58 of file Vector4.cs.

The X component of the Vector4.

Definition at line 43 of file Vector4.cs.

The Y component of the Vector4.

Definition at line 48 of file Vector4.cs.

The Z component of the Vector4.

Definition at line 53 of file Vector4.cs.

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

Defines a zero-length Vector4.

Definition at line 83 of file Vector4.cs.


Property Documentation

float OpenTK.Vector4.Length [get]

Gets the length (magnitude) of the vector.

LengthFast

See also:
LengthSquared

Definition at line 262 of file Vector4.cs.

float OpenTK.Vector4.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 283 of file Vector4.cs.

float OpenTK.Vector4.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 304 of file Vector4.cs.

Vector2 OpenTK.Vector4.Xy [get, set]

Gets or sets an OpenTK.Vector2 with the X and Y components of this instance.

Definition at line 984 of file Vector4.cs.

Vector3 OpenTK.Vector4.Xyz [get, set]

Gets or sets an OpenTK.Vector3 with the X, Y and Z components of this instance.

Definition at line 990 of file Vector4.cs.

 All Classes Functions Variables Enumerations Properties Events

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