Class Vector
Vector represents list of doubles.
public class Vector : List<double>, IList<double>, ICollection<double>, IReadOnlyList<double>, IReadOnlyCollection<double>, IEnumerable<double>, IList, ICollection, IEnumerable, IEquatable<Vector>var vec1 = new Vector { 20, 0, 0 };
var vec2 = new Vector { -10, 15, 5 };
Default constructor.
public Vector()Vector3 initialized by a list of values.
public Vector(IEnumerable<double> values)| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Double> | values | List of values. | 
Adds to each component of the first vector the respective component of the second vector multiplied by a scalar.
public static void AddMulMutate(Vector a, double s, Vector b)| Type | Name | Description | 
|---|---|---|
| Vector | a | First vector. | 
| System.Double | s | Scalar value. | 
| Vector | b | Second vector. | 
Computes the dot product between two vectors.
public static double Dot(Vector a, Vector b)| Type | Name | Description | 
|---|---|---|
| Vector | a | The first vector. | 
| Vector | b | The second vector with which compute the dot product. | 
| Type | Description | 
|---|---|
| System.Double | The dot product. | 
Checks if the two vectors are the same.
Two vectors are the same, if all components of the two vectors are within Epsilon.
public bool Equals(Vector other)| Type | Name | Description | 
|---|---|---|
| Vector | other | The vector to test. | 
| Type | Description | 
|---|---|
| System.Boolean | True if are the same, otherwise false. | 
Checks if the two vectors are the same.
Two vectors are the same, if all components of the two vectors are within Epsilon.
public override bool Equals(object obj)| Type | Name | Description | 
|---|---|---|
| System.Object | obj | The vector to test. | 
| Type | Description | 
|---|---|
| System.Boolean | True if are the same, otherwise false. | 
public override int GetHashCode()| Type | Description | 
|---|---|
| System.Int32 | 
Gets a value indicating whether this vector is valid.
A valid vector must be formed of finite numbers.
public bool IsValid()| Type | Description | 
|---|---|
| System.Boolean | True if the vector is valid. | 
Gets a value indicating whether the X, Y, and Z values are all equal to 0.0.
public bool IsZero()| Type | Description | 
|---|---|
| System.Boolean | True if all the component are less than Epsilon. | 
Computes the length (or magnitude, or size) of this vector.
public double Length()| Type | Description | 
|---|---|
| System.Double | The magnitude of the vector. | 
Reverses this vector in place (reverses the direction).
public static Vector Reverse(Vector a)| Type | Name | Description | 
|---|---|---|
| Vector | a | The vector to reverse. | 
| Type | Description | 
|---|---|
| Vector | The reversed vector. | 
Computes the squared length (or magnitude, or size) of this vector.
public double SquaredLength()| Type | Description | 
|---|---|
| System.Double | The sum of each value squared. | 
Subtracts to each component of the first vector the respective component of the second vector multiplied by a scalar.
public static void SubMulMutate(Vector a, double s, Vector b)| Type | Name | Description | 
|---|---|---|
| Vector | a | First vector. | 
| System.Double | s | Scalar value. | 
| Vector | b | Second vector. | 
Constructs the string representation of the vector.
public override string ToString()| Type | Description | 
|---|---|
| System.String | The vector in string format. | 
Creates a list of zero values.
public static Vector Zero1d(int rows)| Type | Name | Description | 
|---|---|---|
| System.Int32 | rows | Rows dimension. | 
| Type | Description | 
|---|---|
| Vector | Get a vector of r dimension. | 
Creates a 2 dimensional list of zero values.
public static List<Vector> Zero2d(int rows, int cols)| Type | Name | Description | 
|---|---|---|
| System.Int32 | rows | Rows dimension. | 
| System.Int32 | cols | Columns dimension. | 
| Type | Description | 
|---|---|
| System.Collections.Generic.List<Vector> | Get a vector of r*c dimension. | 
Creates a 3 dimensional list of zero values.
public static List<List<Vector>> Zero3d(int rows, int cols, int depth)| Type | Name | Description | 
|---|---|---|
| System.Int32 | rows | Rows dimension. | 
| System.Int32 | cols | Columns dimension. | 
| System.Int32 | depth | Depth dimension. | 
| Type | Description | 
|---|---|
| System.Collections.Generic.List<System.Collections.Generic.List<Vector>> | Get a vector of rcd dimension. | 
Adds two vectors.
public static Vector operator +(Vector a, Vector b)| Type | Name | Description | 
|---|---|---|
| Vector | a | The first vector. | 
| Vector | b | The second vector. | 
| Type | Description | 
|---|---|
| Vector | A vector which is the sum of a and b. | 
Divides a vector by a scalar.
public static Vector operator /(Vector v, double a)| Type | Name | Description | 
|---|---|---|
| Vector | v | The vector to divide. | 
| System.Double | a | The scalar divisor. | 
| Type | Description | 
|---|---|
| Vector | A vector whose magnitude is multiplied by a. | 
Checks if the two vectors are the same.
Two vectors are the same, if all components of the two vectors are within Epsilon.
public static bool operator ==(Vector a, Vector b)| Type | Name | Description | 
|---|---|---|
| Vector | a | First vector. | 
| Vector | b | Second vector. | 
| Type | Description | 
|---|---|
| System.Boolean | True if are the same, otherwise false. | 
Checks if the two vectors are the same.
Two vectors are the same, if all components of the two vectors are within Epsilon.
public static bool operator !=(Vector a, Vector b)| Type | Name | Description | 
|---|---|---|
| Vector | a | First vector. | 
| Vector | b | Second vector. | 
| Type | Description | 
|---|---|
| System.Boolean | True if are the same, otherwise false. | 
Multiplying an n x m matrix by a m x 1. Transform the vector.
public static Vector operator *(Vector v, Matrix m)| Type | Name | Description | 
|---|---|---|
| Vector | v | Vector to transform. | 
| Matrix | m | Matrix to multiply. | 
| Type | Description | 
|---|---|
| Vector | Vector resulting of multiplying an n x m matrix by a m x 1. | 
Multiply a vector and a scalar.
public static Vector operator *(Vector v, double a)| Type | Name | Description | 
|---|---|---|
| Vector | v | The vector to multiply. | 
| System.Double | a | The scalar value to multiply. | 
| Type | Description | 
|---|---|
| Vector | A vector whose magnitude is multiplied by a. | 
Subtracts two vectors.
public static Vector operator -(Vector a, Vector b)| Type | Name | Description | 
|---|---|---|
| Vector | a | The first vector. | 
| Vector | b | The second vector. | 
| Type | Description | 
|---|---|
| Vector | A vector which is the difference between a and b. |