Namespaces

Types in MathNet.Spatial.Euclidean

Type Vector2D

Namespace MathNet.Spatial.Euclidean

Parent ValueType

Interfaces IXmlSerializable, IEquatable<Vector2D>, IFormattable

A struct representing a vector in 2D space

Constructors

Static Functions

Methods

Properties

Fields

Public Constructors

Vector2D(Double[] data)

Initializes a new instance of the Vector2D struct.
Obsolete: This constructor will be removed. Made obsolete 2017-12-03.
Parameters
Double[] data

A list of 2 doubles

Vector2D(double r, Angle a)

Initializes a new instance of the Vector2D struct. Creates a vector with length r rotated a counterclockwise from X-Axis
Obsolete: This constructor will be removed, use FromPolar. Made obsolete 2017-12-03.
Parameters
double r

The radius

Angle a

The angle

Vector2D(double x, double y)

Initializes a new instance of the Vector2D struct.
Parameters
double x

The x component.

double y

The y component.

Vector2D(IEnumerable<double> data)

Initializes a new instance of the Vector2D struct.
Obsolete: This constructor will be removed. Made obsolete 2017-12-03.
Parameters
IEnumerable<double> data

A list of 2 doubles

Public Static Functions

Vector2D FromPolar(double radius, Angle angle)

Creates a Vector from Polar coordinates
Parameters
double radius

The distance of the point from the origin

Angle angle

The angle of the point as measured from the X Axis

Return
Vector2D

A vector.

Vector2D OfVector(Vector<double> vector)

Create a new Vector2D from a Math.NET Numerics vector of length 2.
Parameters
Vector<double> vector

A vector with length 2 to populate the created instance with.

Return
Vector2D

A Vector2D

Vector2D Parse(string value, IFormatProvider formatProvider)

Attempts to convert a string of the form x,y into a point
Parameters
string value

The string to be converted

IFormatProvider formatProvider

The IFormatProvider

Return
Vector2D

A point at the coordinates specified

Vector2D ReadFrom(XmlReader reader)

Creates an Vector2D from an XmlReader.
Parameters
XmlReader reader

An XmlReader positioned at the node to read into this Vector2D.

Return
Vector2D

An Vector2D that contains the data read from the reader.

bool TryParse(string text, IFormatProvider formatProvider, Vector2D& result)

bool TryParse(string text, Vector2D& result)

Public Methods

Vector2D Add(Vector2D v)

Adds a vector to this vector
Parameters
Vector2D v

A vector to add

Return
Vector2D

A new vector which is the sum of the existing vector and the provided vector

Angle AngleTo(Vector2D other)

Compute the angle between this vector and another using the arccosine of the dot product.
Parameters
Vector2D other

The other Vector2D

Return
Angle

The angle between vectors, with a range between 0° and 180°

double CrossProduct(Vector2D other)

Performs the 2D 'cross product' as if the 2D vectors were really 3D vectors in the z=0 plane, returning the scalar magnitude and direction of the resulting z value. Formula: (this.X * other.Y) - (this.Y * other.X)
Parameters
Vector2D other

The other Vector2D

Return
double

(this.X * other.Y) - (this.Y * other.X)

double DotProduct(Vector2D other)

Perform the dot product on a pair of vectors
Parameters
Vector2D other

The second vector

Return
double

The result of the dot product.

bool Equals(object obj)

bool Equals(Vector2D other)

bool Equals(Vector2D other, double tolerance)

Compare this instance with other
Parameters
Vector2D other

The other Vector2D

double tolerance

The tolerance when comparing the x and y components

Return
bool

True if found to be equal.

int GetHashCode()

Type GetType()

bool IsParallelTo(Vector2D other, Angle tolerance)

Computes whether or not this vector is parallel to another vector within a given angle tolerance.
Parameters
Vector2D other

The other Vector2D

Angle tolerance

The tolerance for when vectors are said to be parallel

Return
bool

True if the vectors are parallel within the angle tolerance, false if they are not

bool IsParallelTo(Vector2D other, double tolerance)

Computes whether or not this vector is perpendicular to other vector by: 1. Normalizing both 2. Computing the dot product. 3. Comparing 1- Math.Abs(dot product) to tolerance
Parameters
Vector2D other

The other Vector2D

double tolerance

The tolerance for when vectors are said to be parallel

Return
bool

True if the vector dot product is within the given double tolerance of unity, false if not

bool IsPerpendicularTo(Vector2D other, Angle tolerance)

Computes whether or not this vector is parallel to another vector within a given angle tolerance.
Parameters
Vector2D other

The other Vector2D

Angle tolerance

The tolerance for when vectors are said to be parallel

Return
bool

True if the vectors are parallel within the angle tolerance, false if they are not

bool IsPerpendicularTo(Vector2D other, double tolerance)

Computes whether or not this vector is perpendicular to other vector by: 1. Normalizing both 2. Computing the dot product. 3. Comparing Math.Abs(dot product) to tolerance
Parameters
Vector2D other

The other Vector2D

double tolerance

The tolerance for when vectors are said to be parallel

Return
bool

True if the vector dot product is within the given double tolerance of unity, false if not

Vector2D Negate()

Returns the negative of the vector
Return
Vector2D

A new negated vector.

Vector2D Normalize()

Creates a new unit vector from the existing vector.
Return
Vector2D

A new unit vector in the same direction as the original vector

Vector2D ProjectOn(Vector2D other)

Projects this vector onto another vector
Parameters
Vector2D other

The other Vector2D

Return
Vector2D

A Vector2D representing this vector projected on other

Vector2D Rotate(Angle angle)

Rotates a Vector by an angle
Parameters
Angle angle

The angle.

Return
Vector2D

A new rotated vector.

Vector2D Rotate<T>(double angle, T angleUnit)

Rotates a Vector
Obsolete: This method will be removed, use the overload that takes an Angle. Made obsolete 2017-12-03.
Parameters
double angle

An angle

T angleUnit

A type of angle

Return
Vector2D

A new vector

Vector2D ScaleBy(double d)

Scales the vector by the provided value
Parameters
double d

a scaling factor

Return
Vector2D

A new scale adjusted vector

Angle SignedAngleTo(Vector2D other, bool clockWise, bool returnNegative)

Compute the signed angle to another vector.
Parameters
Vector2D other

The other Vector2D

bool clockWise

Positive in clockwise direction

bool returnNegative

When true and the result is > 180° a negative value is returned

Return
Angle

The angle between the vectors.

Vector2D Subtract(Vector2D v)

Subtracts a vector from this vector.
Parameters
Vector2D v

A vector to subtract

Return
Vector2D

A new vector which is the difference of the current vector and the provided vector

string ToString()

string ToString(IFormatProvider provider)

Returns a string representation of this instance using the provided IFormatProvider
Parameters
IFormatProvider provider

A IFormatProvider

Return
string

The string representation of this instance.

string ToString(string format, IFormatProvider provider)

Vector<double> ToVector()

Convert to a Math.NET Numerics dense vector of length 2.
Return
Vector<double>

A Vector`1 with the x and y values from this instance.

Vector2D TransformBy(Matrix<double> m)

Transforms a vector by multiplying it against a provided matrix
Parameters
Matrix<double> m

The matrix to multiply

Return
Vector2D

A new transformed vector

Public Properties

double Length get;

Gets the length of the vector

Vector2D XAxis get;

Gets a vector representing the X Axis

Vector2D YAxis get;

Gets a vector representing the Y Axis

Public fields

double X

The x component.
return double

double Y

The y component.
return double