The Open Toolkit library
1.0
|
Represents a 3D vector using three single-precision floating-point numbers. More...
Inherits IEquatable< Vector3 >.
Public Member Functions | |
Vector3 (float value) | |
Constructs a new instance. More... | |
Vector3 (float x, float y, float z) | |
Constructs a new Vector3. More... | |
Vector3 (Vector2 v) | |
Constructs a new Vector3 from the given Vector2. More... | |
Vector3 (Vector3 v) | |
Constructs a new Vector3 from the given Vector3. More... | |
Vector3 (Vector4 v) | |
Constructs a new Vector3 from the given Vector4. More... | |
void | Add (Vector3 right) |
Add the Vector passed as parameter to this instance. More... | |
void | Add (ref Vector3 right) |
Add the Vector passed as parameter to this instance. More... | |
void | Sub (Vector3 right) |
Subtract the Vector passed as parameter from this instance. More... | |
void | Sub (ref Vector3 right) |
Subtract the Vector passed as parameter from this instance. More... | |
void | Mult (float f) |
Multiply this instance by a scalar. More... | |
void | Div (float f) |
Divide this instance by a scalar. More... | |
Vector3 | Normalized () |
Returns a copy of the Vector3 scaled to unit length. More... | |
void | Normalize () |
Scales the Vector3 to unit length. More... | |
void | NormalizeFast () |
Scales the Vector3 to approximately unit length. More... | |
void | Scale (float sx, float sy, float sz) |
Scales the current Vector3 by the given amounts. More... | |
void | Scale (Vector3 scale) |
Scales this instance by the given parameter. More... | |
void | Scale (ref Vector3 scale) |
Scales this instance by the given parameter. More... | |
override string | ToString () |
Returns a System.String that represents the current Vector3. More... | |
override int | GetHashCode () |
Returns the hashcode for this instance. More... | |
override bool | Equals (object obj) |
Indicates whether this instance and a specified object are equal. More... | |
bool | Equals (Vector3 other) |
Indicates whether the current vector is equal to another vector. More... | |
Static Public Member Functions | |
static Vector3 | Sub (Vector3 a, Vector3 b) |
Subtract one Vector from another More... | |
static void | Sub (ref Vector3 a, ref Vector3 b, out Vector3 result) |
Subtract one Vector from another More... | |
static Vector3 | Mult (Vector3 a, float f) |
Multiply a vector and a scalar More... | |
static void | Mult (ref Vector3 a, float f, out Vector3 result) |
Multiply a vector and a scalar More... | |
static Vector3 | Div (Vector3 a, float f) |
Divide a vector by a scalar More... | |
static void | Div (ref Vector3 a, float f, out Vector3 result) |
Divide a vector by a scalar More... | |
static Vector3 | Add (Vector3 a, Vector3 b) |
Adds two vectors. More... | |
static void | Add (ref Vector3 a, ref Vector3 b, out Vector3 result) |
Adds two vectors. More... | |
static Vector3 | Subtract (Vector3 a, Vector3 b) |
Subtract one Vector from another More... | |
static void | Subtract (ref Vector3 a, ref Vector3 b, out Vector3 result) |
Subtract one Vector from another More... | |
static Vector3 | Multiply (Vector3 vector, float scale) |
Multiplies a vector by a scalar. More... | |
static void | Multiply (ref Vector3 vector, float scale, out Vector3 result) |
Multiplies a vector by a scalar. More... | |
static Vector3 | Multiply (Vector3 vector, Vector3 scale) |
Multiplies a vector by the components a vector (scale). More... | |
static void | Multiply (ref Vector3 vector, ref Vector3 scale, out Vector3 result) |
Multiplies a vector by the components of a vector (scale). More... | |
static Vector3 | Divide (Vector3 vector, float scale) |
Divides a vector by a scalar. More... | |
static void | Divide (ref Vector3 vector, float scale, out Vector3 result) |
Divides a vector by a scalar. More... | |
static Vector3 | Divide (Vector3 vector, Vector3 scale) |
Divides a vector by the components of a vector (scale). More... | |
static void | Divide (ref Vector3 vector, ref Vector3 scale, out Vector3 result) |
Divide a vector by the components of a vector (scale). More... | |
static Vector3 | ComponentMin (Vector3 a, Vector3 b) |
Calculate the component-wise minimum of two vectors More... | |
static void | ComponentMin (ref Vector3 a, ref Vector3 b, out Vector3 result) |
Calculate the component-wise minimum of two vectors More... | |
static Vector3 | ComponentMax (Vector3 a, Vector3 b) |
Calculate the component-wise maximum of two vectors More... | |
static void | ComponentMax (ref Vector3 a, ref Vector3 b, out Vector3 result) |
Calculate the component-wise maximum of two vectors More... | |
static Vector3 | Min (Vector3 left, Vector3 right) |
Returns the Vector3 with the minimum magnitude More... | |
static Vector3 | Max (Vector3 left, Vector3 right) |
Returns the Vector3 with the minimum magnitude More... | |
static Vector3 | Clamp (Vector3 vec, Vector3 min, Vector3 max) |
Clamp a vector to the given minimum and maximum vectors More... | |
static void | Clamp (ref Vector3 vec, ref Vector3 min, ref Vector3 max, out Vector3 result) |
Clamp a vector to the given minimum and maximum vectors More... | |
static Vector3 | Normalize (Vector3 vec) |
Scale a vector to unit length More... | |
static void | Normalize (ref Vector3 vec, out Vector3 result) |
Scale a vector to unit length More... | |
static Vector3 | NormalizeFast (Vector3 vec) |
Scale a vector to approximately unit length More... | |
static void | NormalizeFast (ref Vector3 vec, out Vector3 result) |
Scale a vector to approximately unit length More... | |
static float | Dot (Vector3 left, Vector3 right) |
Calculate the dot (scalar) product of two vectors More... | |
static void | Dot (ref Vector3 left, ref Vector3 right, out float result) |
Calculate the dot (scalar) product of two vectors More... | |
static Vector3 | Cross (Vector3 left, Vector3 right) |
Caclulate the cross (vector) product of two vectors More... | |
static void | Cross (ref Vector3 left, ref Vector3 right, out Vector3 result) |
Caclulate the cross (vector) product of two vectors More... | |
static Vector3 | Lerp (Vector3 a, Vector3 b, float blend) |
Returns a new Vector that is the linear blend of the 2 given Vectors More... | |
static void | Lerp (ref Vector3 a, ref Vector3 b, float blend, out Vector3 result) |
Returns a new Vector that is the linear blend of the 2 given Vectors More... | |
static Vector3 | BaryCentric (Vector3 a, Vector3 b, Vector3 c, float u, float v) |
Interpolate 3 Vectors using Barycentric coordinates More... | |
static void | BaryCentric (ref Vector3 a, ref Vector3 b, ref Vector3 c, float u, float v, out Vector3 result) |
Interpolate 3 Vectors using Barycentric coordinates More... | |
static Vector3 | TransformVector (Vector3 vec, Matrix4 mat) |
Transform a direction vector by the given Matrix Assumes the matrix has a bottom row of (0,0,0,1), that is the translation part is ignored. More... | |
static void | TransformVector (ref Vector3 vec, ref Matrix4 mat, out Vector3 result) |
Transform a direction vector by the given Matrix Assumes the matrix has a bottom row of (0,0,0,1), that is the translation part is ignored. More... | |
static Vector3 | TransformNormal (Vector3 norm, Matrix4 mat) |
Transform a Normal by the given Matrix More... | |
static void | TransformNormal (ref Vector3 norm, ref Matrix4 mat, out Vector3 result) |
Transform a Normal by the given Matrix More... | |
static Vector3 | TransformNormalInverse (Vector3 norm, Matrix4 invMat) |
Transform a Normal by the (transpose of the) given Matrix More... | |
static void | TransformNormalInverse (ref Vector3 norm, ref Matrix4 invMat, out Vector3 result) |
Transform a Normal by the (transpose of the) given Matrix More... | |
static Vector3 | TransformPosition (Vector3 pos, Matrix4 mat) |
Transform a Position by the given Matrix More... | |
static void | TransformPosition (ref Vector3 pos, ref Matrix4 mat, out Vector3 result) |
Transform a Position by the given Matrix More... | |
static Vector3 | Transform (Vector3 vec, Matrix4 mat) |
Transform a Vector by the given Matrix More... | |
static void | Transform (ref Vector3 vec, ref Matrix4 mat, out Vector3 result) |
Transform a Vector by the given Matrix More... | |
static Vector3 | Transform (Vector3 vec, Quaternion quat) |
Transforms a vector by a quaternion rotation. More... | |
static void | Transform (ref Vector3 vec, ref Quaternion quat, out Vector3 result) |
Transforms a vector by a quaternion rotation. More... | |
static Vector3 | TransformPerspective (Vector3 vec, Matrix4 mat) |
Transform a Vector3 by the given Matrix, and project the resulting Vector4 back to a Vector3 More... | |
static void | TransformPerspective (ref Vector3 vec, ref Matrix4 mat, out Vector3 result) |
Transform a Vector3 by the given Matrix, and project the resulting Vector4 back to a Vector3 More... | |
static float | CalculateAngle (Vector3 first, Vector3 second) |
Calculates the angle (in radians) between two vectors. More... | |
static void | CalculateAngle (ref Vector3 first, ref Vector3 second, out float result) |
Calculates the angle (in radians) between two vectors. More... | |
static Vector3 | operator+ (Vector3 left, Vector3 right) |
Adds two instances. More... | |
static Vector3 | operator- (Vector3 left, Vector3 right) |
Subtracts two instances. More... | |
static Vector3 | operator- (Vector3 vec) |
Negates an instance. More... | |
static Vector3 | operator* (Vector3 vec, float scale) |
Multiplies an instance by a scalar. More... | |
static Vector3 | operator* (float scale, Vector3 vec) |
Multiplies an instance by a scalar. More... | |
static Vector3 | operator/ (Vector3 vec, float scale) |
Divides an instance by a scalar. More... | |
static bool | operator== (Vector3 left, Vector3 right) |
Compares two instances for equality. More... | |
static bool | operator!= (Vector3 left, Vector3 right) |
Compares two instances for inequality. More... | |
Public Attributes | |
float | X |
The X component of the Vector3. More... | |
float | Y |
The Y component of the Vector3. More... | |
float | Z |
The Z component of the Vector3. More... | |
Static Public Attributes | |
static readonly Vector3 | UnitX = new Vector3(1, 0, 0) |
Defines a unit-length Vector3 that points towards the X-axis. More... | |
static readonly Vector3 | UnitY = new Vector3(0, 1, 0) |
Defines a unit-length Vector3 that points towards the Y-axis. More... | |
static readonly Vector3 | UnitZ = new Vector3(0, 0, 1) |
/// Defines a unit-length Vector3 that points towards the Z-axis. More... | |
static readonly Vector3 | Zero = new Vector3(0, 0, 0) |
Defines a zero-length Vector3. More... | |
static readonly Vector3 | One = new Vector3(1, 1, 1) |
Defines an instance with all components set to 1. More... | |
static readonly int | SizeInBytes = Marshal.SizeOf(new Vector3()) |
Defines the size of the Vector3 struct in bytes. More... | |
Properties | |
float | this[int index] [get, set] |
Gets or sets the value at the index of the Vector. More... | |
float | Length [get] |
Gets the length (magnitude) of the vector. More... | |
float | LengthFast [get] |
Gets an approximation of the vector length (magnitude). More... | |
float | LengthSquared [get] |
Gets the square of the vector length (magnitude). More... | |
Vector2 | Xy [get, set] |
Gets or sets an OpenTK.Vector2 with the X and Y components of this instance. More... | |
Vector2 | Xz [get, set] |
Gets or sets an OpenTK.Vector2 with the X and Z components of this instance. More... | |
Vector2 | Yx [get, set] |
Gets or sets an OpenTK.Vector2 with the Y and X components of this instance. More... | |
Vector2 | Yz [get, set] |
Gets or sets an OpenTK.Vector2 with the Y and Z components of this instance. More... | |
Vector2 | Zx [get, set] |
Gets or sets an OpenTK.Vector2 with the Z and X components of this instance. More... | |
Vector2 | Zy [get, set] |
Gets or sets an OpenTK.Vector2 with the Z and Y components of this instance. More... | |
Vector3 | Xzy [get, set] |
Gets or sets an OpenTK.Vector3 with the X, Z, and Y components of this instance. More... | |
Vector3 | Yxz [get, set] |
Gets or sets an OpenTK.Vector3 with the Y, X, and Z components of this instance. More... | |
Vector3 | Yzx [get, set] |
Gets or sets an OpenTK.Vector3 with the Y, Z, and X components of this instance. More... | |
Vector3 | Zxy [get, set] |
Gets or sets an OpenTK.Vector3 with the Z, X, and Y components of this instance. More... | |
Vector3 | Zyx [get, set] |
Gets or sets an OpenTK.Vector3 with the Z, Y, and X components of this instance. More... | |
Represents a 3D vector using three single-precision floating-point numbers.
The Vector3 structure is suitable for interoperation with unmanaged code requiring three consecutive floats.
OpenTK.Vector3.Vector3 | ( | float | value | ) |
Constructs a new instance.
value | The value that will initialize this instance. |
OpenTK.Vector3.Vector3 | ( | float | x, |
float | y, | ||
float | z | ||
) |
OpenTK.Vector3.Vector3 | ( | Vector2 | v | ) |
OpenTK.Vector3.Vector3 | ( | Vector3 | v | ) |
OpenTK.Vector3.Vector3 | ( | Vector4 | v | ) |
void OpenTK.Vector3.Add | ( | Vector3 | right | ) |
Add the Vector passed as parameter to this instance.
right | Right operand. This parameter is only read from. |
void OpenTK.Vector3.Add | ( | ref Vector3 | right | ) |
Add the Vector passed as parameter to this instance.
right | Right operand. This parameter is only read from. |
Adds two vectors.
a | Left operand. |
b | Right operand. |
Adds two vectors.
a | Left operand. |
b | Right operand. |
result | Result of operation. |
|
static |
Interpolate 3 Vectors using Barycentric coordinates
a | First input Vector |
b | Second input Vector |
c | Third input Vector |
u | First Barycentric Coordinate |
v | Second Barycentric Coordinate |
|
static |
Interpolate 3 Vectors using Barycentric coordinates
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 |
Calculates the angle (in radians) between two vectors.
first | The first vector. |
second | The second vector. |
Note that the returned angle is never bigger than the constant Pi.
|
static |
Calculates the angle (in radians) between two vectors.
first | The first vector. |
second | The second vector. |
result | Angle (in radians) between the vectors. |
Note that the returned angle is never bigger than the constant Pi.
Clamp a vector to the given minimum and maximum vectors
vec | Input vector |
min | Minimum vector |
max | Maximum vector |
|
static |
Clamp a vector to the given minimum and maximum vectors
vec | Input vector |
min | Minimum vector |
max | Maximum vector |
result | The clamped vector |
Calculate the component-wise maximum of two vectors
a | First operand |
b | Second operand |
Calculate the component-wise maximum of two vectors
a | First operand |
b | Second operand |
result | The component-wise maximum |
Calculate the component-wise minimum of two vectors
a | First operand |
b | Second operand |
Calculate the component-wise minimum of two vectors
a | First operand |
b | Second operand |
result | The component-wise minimum |
Caclulate the cross (vector) product of two vectors
left | First operand |
right | Second operand |
Caclulate the cross (vector) product of two vectors
left | First operand |
right | Second operand |
result | The cross product of the two inputs |
void OpenTK.Vector3.Div | ( | float | f | ) |
Divide this instance by a scalar.
f | Scalar operand. |
Divide a vector by a scalar
a | Vector operand |
f | Scalar operand |
Divide a vector by a scalar
a | Vector operand |
f | Scalar operand |
result | Result of the division |
Divides a vector by a scalar.
vector | Left operand. |
scale | Right operand. |
Divides a vector by a scalar.
vector | Left operand. |
scale | Right operand. |
result | Result of the operation. |
Divides a vector by the components of a vector (scale).
vector | Left operand. |
scale | Right operand. |
|
static |
Divide a vector by the components of a vector (scale).
vector | Left operand. |
scale | Right operand. |
result | Result of the operation. |
Calculate the dot (scalar) product of two vectors
left | First operand |
right | Second operand |
Calculate the dot (scalar) product of two vectors
left | First operand |
right | Second operand |
result | The dot product of the two inputs |
override bool OpenTK.Vector3.Equals | ( | object | obj | ) |
Indicates whether this instance and a specified object are equal.
obj | The object to compare to. |
bool OpenTK.Vector3.Equals | ( | Vector3 | other | ) |
Indicates whether the current vector is equal to another vector.
other | A vector to compare with this vector. |
override int OpenTK.Vector3.GetHashCode | ( | ) |
Returns the hashcode for this instance.
Returns a new Vector that is the linear blend of the 2 given Vectors
a | First input vector |
b | Second input vector |
blend | The blend factor. a when blend=0, b when blend=1. |
|
static |
Returns a new Vector that is the linear blend of the 2 given Vectors
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 |
void OpenTK.Vector3.Mult | ( | float | f | ) |
Multiply this instance by a scalar.
f | Scalar operand. |
Multiply a vector and a scalar
a | Vector operand |
f | Scalar operand |
Multiply a vector and a scalar
a | Vector operand |
f | Scalar operand |
result | Result of the multiplication |
Multiplies a vector by a scalar.
vector | Left operand. |
scale | Right operand. |
Multiplies a vector by a scalar.
vector | Left operand. |
scale | Right operand. |
result | Result of the operation. |
Multiplies a vector by the components a vector (scale).
vector | Left operand. |
scale | Right operand. |
|
static |
Multiplies a vector by the components of a vector (scale).
vector | Left operand. |
scale | Right operand. |
result | Result of the operation. |
void OpenTK.Vector3.Normalize | ( | ) |
Scales the Vector3 to unit length.
Scale a vector to unit length
vec | The input vector |
Scale a vector to unit length
vec | The input vector |
result | The normalized vector |
void OpenTK.Vector3.NormalizeFast | ( | ) |
Scales the Vector3 to approximately unit length.
Scale a vector to approximately unit length
vec | The input vector |
Scale a vector to approximately unit length
vec | The input vector |
result | The normalized vector |
Compares two instances for inequality.
left | The first instance. |
right | The second instance. |
Multiplies an instance by a scalar.
vec | The instance. |
scale | The scalar. |
Multiplies an instance by a scalar.
scale | The scalar. |
vec | The instance. |
Adds two instances.
left | The first instance. |
right | The second instance. |
Subtracts two instances.
left | The first instance. |
right | The second instance. |
Negates an instance.
vec | The instance. |
Divides an instance by a scalar.
vec | The instance. |
scale | The scalar. |
Compares two instances for equality.
left | The first instance. |
right | The second instance. |
void OpenTK.Vector3.Scale | ( | float | sx, |
float | sy, | ||
float | sz | ||
) |
Scales the current Vector3 by the given amounts.
sx | The scale of the X component. |
sy | The scale of the Y component. |
sz | The scale of the Z component. |
void OpenTK.Vector3.Scale | ( | Vector3 | scale | ) |
Scales this instance by the given parameter.
scale | The scaling of the individual components. |
void OpenTK.Vector3.Scale | ( | ref Vector3 | scale | ) |
Scales this instance by the given parameter.
scale | The scaling of the individual components. |
void OpenTK.Vector3.Sub | ( | Vector3 | right | ) |
Subtract the Vector passed as parameter from this instance.
right | Right operand. This parameter is only read from. |
void OpenTK.Vector3.Sub | ( | ref Vector3 | right | ) |
Subtract the Vector passed as parameter from this instance.
right | Right operand. This parameter is only read from. |
Subtract one Vector from another
a | First operand |
b | Second operand |
Subtract one Vector from another
a | First operand |
b | Second operand |
result | Result of subtraction |
Subtract one Vector from another
a | First operand |
b | Second operand |
Subtract one Vector from another
a | First operand |
b | Second operand |
result | Result of subtraction |
override string OpenTK.Vector3.ToString | ( | ) |
Returns a System.String that represents the current Vector3.
Transform a Vector by the given Matrix
vec | The vector to transform |
mat | The desired transformation |
|
static |
Transform a Vector by the given Matrix
vec | The vector to transform |
mat | The desired transformation |
result | The transformed vector |
|
static |
Transforms a vector by a quaternion rotation.
vec | The vector to transform. |
quat | The quaternion to rotate the vector by. |
|
static |
Transforms a vector by a quaternion rotation.
vec | The vector to transform. |
quat | The quaternion to rotate the vector by. |
result | The result of the operation. |
Transform a Normal by the given Matrix
This calculates the inverse of the given matrix, use TransformNormalInverse if you already have the inverse to avoid this extra calculation
norm | The normal to transform |
mat | The desired transformation |
|
static |
Transform a Normal by the given Matrix
This calculates the inverse of the given matrix, use TransformNormalInverse if you already have the inverse to avoid this extra calculation
norm | The normal to transform |
mat | The desired transformation |
result | The transformed normal |
Transform a Normal by the (transpose of the) given Matrix
This version doesn't calculate the inverse matrix. Use this version if you already have the inverse of the desired transform to hand
norm | The normal to transform |
invMat | The inverse of the desired transformation |
|
static |
Transform a Normal by the (transpose of the) given Matrix
This version doesn't calculate the inverse matrix. Use this version if you already have the inverse of the desired transform to hand
norm | The normal to transform |
invMat | The inverse of the desired transformation |
result | The transformed normal |
Transform a Position by the given Matrix
pos | The position to transform |
mat | The desired transformation |
|
static |
Transform a Position by the given Matrix
pos | The position to transform |
mat | The desired transformation |
result | The transformed position |
Transform a direction vector by the given Matrix Assumes the matrix has a bottom row of (0,0,0,1), that is the translation part is ignored.
vec | The vector to transform |
mat | The desired transformation |
|
static |
Transform a direction vector by the given Matrix Assumes the matrix has a bottom row of (0,0,0,1), that is the translation part is ignored.
vec | The vector to transform |
mat | The desired transformation |
result | The transformed vector |
Defines an instance with all components set to 1.
|
static |
Defines the size of the Vector3 struct in bytes.
Defines a unit-length Vector3 that points towards the X-axis.
Defines a unit-length Vector3 that points towards the Y-axis.
/// Defines a unit-length Vector3 that points towards the Z-axis.
float OpenTK.Vector3.X |
The X component of the Vector3.
float OpenTK.Vector3.Y |
The Y component of the Vector3.
float OpenTK.Vector3.Z |
The Z component of the Vector3.
|
get |
|
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.
|
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.
|
getset |
Gets or sets the value at the index of the Vector.
|
getset |
Gets or sets an OpenTK.Vector2 with the X and Y components of this instance.
|
getset |
Gets or sets an OpenTK.Vector2 with the X and Z components of this instance.
|
getset |
Gets or sets an OpenTK.Vector3 with the X, Z, and Y components of this instance.
|
getset |
Gets or sets an OpenTK.Vector2 with the Y and X components of this instance.
|
getset |
Gets or sets an OpenTK.Vector3 with the Y, X, and Z components of this instance.
|
getset |
Gets or sets an OpenTK.Vector2 with the Y and Z components of this instance.
|
getset |
Gets or sets an OpenTK.Vector3 with the Y, Z, and X components of this instance.
|
getset |
Gets or sets an OpenTK.Vector2 with the Z and X components of this instance.
|
getset |
Gets or sets an OpenTK.Vector3 with the Z, X, and Y components of this instance.
|
getset |
Gets or sets an OpenTK.Vector2 with the Z and Y components of this instance.
|
getset |
Gets or sets an OpenTK.Vector3 with the Z, Y, and X components of this instance.