Struct Vector2
Represent a two component vector of double precision.
Implements
Inherited Members
Namespace: netDxf
Assembly: CADability.dll
Syntax
public struct Vector2 : IEquatable<Vector2>
Constructors
| Improve this Doc View SourceVector2(Double)
Initializes a new instance of Vector3.
Declaration
public Vector2(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | value | X, Y component. |
Vector2(Double, Double)
Initializes a new instance of Vector2.
Declaration
public Vector2(double x, double y)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | x | X component. |
| System.Double | y | Y component. |
Vector2(Double[])
Initializes a new instance of Vector2.
Declaration
public Vector2(double[] array)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double[] | array | Array of two elements that represents the vector. |
Properties
| Improve this Doc View SourceIsNormalized
Gets if the vector has been normalized.
Declaration
public bool IsNormalized { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Item[Int32]
Gets or sets a vector element defined by its index.
Declaration
public double this[int index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | Index of the element. |
Property Value
| Type | Description |
|---|---|
| System.Double |
NaN
Represents a vector with not a number components.
Declaration
public static Vector2 NaN { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
UnitX
Unit X vector.
Declaration
public static Vector2 UnitX { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
UnitY
Unit Y vector.
Declaration
public static Vector2 UnitY { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
X
Gets or sets the X component.
Declaration
public double X { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Y
Gets or sets the Y component.
Declaration
public double Y { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Zero
Zero vector.
Declaration
public static Vector2 Zero { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
Methods
| Improve this Doc View SourceAdd(Vector2, Vector2)
Adds two vectors.
Declaration
public static Vector2 Add(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| Vector2 | The addition of u plus v. |
Angle(Vector2)
Obtains the angle of a vector.
Declaration
public static double Angle(Vector2 u)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | A Vector2. |
Returns
| Type | Description |
|---|---|
| System.Double | Angle in radians. |
Angle(Vector2, Vector2)
Obtains the angle of a line defined by two points.
Declaration
public static double Angle(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | A Vector2. |
| Vector2 | v | A Vector2. |
Returns
| Type | Description |
|---|---|
| System.Double | Angle in radians. |
AngleBetween(Vector2, Vector2)
Obtains the angle between two vectors.
Declaration
public static double AngleBetween(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| System.Double | Angle in radians. |
AreParallel(Vector2, Vector2)
Checks if two vectors are parallel.
Declaration
public static bool AreParallel(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if are parallel or false in any other case. |
AreParallel(Vector2, Vector2, Double)
Checks if two vectors are parallel.
Declaration
public static bool AreParallel(Vector2 u, Vector2 v, double threshold)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
| System.Double | threshold | Tolerance used. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if are parallel or false in any other case. |
ArePerpendicular(Vector2, Vector2)
Checks if two vectors are perpendicular.
Declaration
public static bool ArePerpendicular(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if are perpendicular or false in any other case. |
ArePerpendicular(Vector2, Vector2, Double)
Checks if two vectors are perpendicular.
Declaration
public static bool ArePerpendicular(Vector2 u, Vector2 v, double threshold)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
| System.Double | threshold | Tolerance used. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if are perpendicular or false in any other case. |
CrossProduct(Vector2, Vector2)
Obtains the cross product of two vectors.
Declaration
public static double CrossProduct(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| System.Double | Vector2. |
Distance(Vector2, Vector2)
Obtains the distance between two points.
Declaration
public static double Distance(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| System.Double | Distance. |
Divide(Vector2, Vector2)
Divides two vectors component by component.
Declaration
public static Vector2 Divide(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| Vector2 | The multiplication of u times v. |
Divide(Vector2, Double)
Divides a vector with an scalar.
Declaration
public static Vector2 Divide(Vector2 u, double a)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| System.Double | a | Scalar. |
Returns
| Type | Description |
|---|---|
| Vector2 | The division of u times a. |
DotProduct(Vector2, Vector2)
Obtains the dot product of two vectors.
Declaration
public static double DotProduct(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| System.Double | The dot product. |
Equals(Vector2)
Check if the components of two vectors are approximate equals.
Declaration
public bool Equals(Vector2 other)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | other | Another Vector2 to compare to. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the three components are almost equal or false in any other case. |
Equals(Vector2, Vector2)
Check if the components of two vectors are approximate equal.
Declaration
public static bool Equals(Vector2 a, Vector2 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | Vector2. |
| Vector2 | b | Vector2. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the two components are almost equal or false in any other case. |
Equals(Vector2, Vector2, Double)
Check if the components of two vectors are approximate equal.
Declaration
public static bool Equals(Vector2 a, Vector2 b, double threshold)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | Vector2. |
| Vector2 | b | Vector2. |
| System.Double | threshold | Maximum tolerance. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the two components are almost equal or false in any other case. |
Equals(Vector2, Double)
Check if the components of two vectors are approximate equals.
Declaration
public bool Equals(Vector2 other, double threshold)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | other | Another Vector2 to compare to. |
| System.Double | threshold | Maximum tolerance. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the three components are almost equal or false in any other case. |
Equals(Object)
Indicates whether this instance and a specified object are equal.
Declaration
public override bool Equals(object other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | other | Another object to compare to. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if obj and this instance are the same type and represent the same value; otherwise, false. |
Overrides
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | A 32-bit signed integer that is the hash code for this instance. |
Overrides
IsNaN(Vector2)
Returns a value indicating if any component of the specified vector evaluates to a value that is not a number System.Double.NaN.
Declaration
public static bool IsNaN(Vector2 u)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true if any component of the specified vector evaluates to System.Double.NaN; otherwise, false. |
MidPoint(Vector2, Vector2)
Obtains the midpoint.
Declaration
public static Vector2 MidPoint(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| Vector2 | Vector2. |
Modulus()
Obtains the modulus of the vector.
Declaration
public double Modulus()
Returns
| Type | Description |
|---|---|
| System.Double | Vector modulus. |
Multiply(Vector2, Vector2)
Multiplies two vectors component by component.
Declaration
public static Vector2 Multiply(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| Vector2 | The multiplication of u times v. |
Multiply(Vector2, Double)
Multiplies a vector with an scalar.
Declaration
public static Vector2 Multiply(Vector2 u, double a)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| System.Double | a | Scalar. |
Returns
| Type | Description |
|---|---|
| Vector2 | The multiplication of u times a. |
Multiply(Double, Vector2)
Multiplies a scalar with a vector.
Declaration
public static Vector2 Multiply(double a, Vector2 u)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | a | Scalar. |
| Vector2 | u | Vector3. |
Returns
| Type | Description |
|---|---|
| Vector2 | The multiplication of u times a. |
Negate(Vector2)
Negates a vector.
Declaration
public static Vector2 Negate(Vector2 u)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
Returns
| Type | Description |
|---|---|
| Vector2 | The negative vector of u. |
Normalize()
Normalizes the vector.
Declaration
public void Normalize()
Normalize(Vector2)
Normalizes the vector.
Declaration
public static Vector2 Normalize(Vector2 u)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector to normalize |
Returns
| Type | Description |
|---|---|
| Vector2 | A normalized vector. |
Perpendicular(Vector2)
Obtains the counter clockwise perpendicular vector.
Declaration
public static Vector2 Perpendicular(Vector2 u)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
Returns
| Type | Description |
|---|---|
| Vector2 | Vector2. |
Polar(Vector2, Double, Double)
Obtains the polar point of another point.
Declaration
public static Vector2 Polar(Vector2 u, double distance, double angle)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Reference point. |
| System.Double | distance | Distance from point u. |
| System.Double | angle | Angle in radians. |
Returns
| Type | Description |
|---|---|
| Vector2 | The polar point of the specified point. |
Rotate(Vector2, Double)
Rotates a vector.
Declaration
public static Vector2 Rotate(Vector2 u, double angle)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| System.Double | angle | Rotation angles in radians. |
Returns
| Type | Description |
|---|---|
| Vector2 |
Round(Vector2, Int32)
Rounds the components of a vector.
Declaration
public static Vector2 Round(Vector2 u, int numDigits)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| System.Int32 | numDigits | Number of decimal places in the return value. |
Returns
| Type | Description |
|---|---|
| Vector2 | Vector2. |
SquareDistance(Vector2, Vector2)
Obtains the square distance between two points.
Declaration
public static double SquareDistance(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| System.Double | Square distance. |
Subtract(Vector2, Vector2)
Subtracts two vectors.
Declaration
public static Vector2 Subtract(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector3. |
| Vector2 | v | Vector3. |
Returns
| Type | Description |
|---|---|
| Vector2 | The subtraction of u minus v. |
ToArray()
Returns an array that represents the vector.
Declaration
public double[] ToArray()
Returns
| Type | Description |
|---|---|
| System.Double[] | Array. |
ToString()
Obtains a string that represents the vector.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A string text. |
Overrides
ToString(IFormatProvider)
Obtains a string that represents the vector.
Declaration
public string ToString(IFormatProvider provider)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IFormatProvider | provider | An IFormatProvider interface implementation that supplies culture-specific formatting information. |
Returns
| Type | Description |
|---|---|
| System.String | A string text. |
Operators
| Improve this Doc View SourceAddition(Vector2, Vector2)
Adds two vectors.
Declaration
public static Vector2 operator +(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| Vector2 | The addition of u plus v. |
Division(Vector2, Vector2)
Divides two vectors component by component.
Declaration
public static Vector2 operator /(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| Vector2 | The multiplication of u times v. |
Division(Vector2, Double)
Divides a vector with an scalar.
Declaration
public static Vector2 operator /(Vector2 u, double a)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| System.Double | a | Scalar. |
Returns
| Type | Description |
|---|---|
| Vector2 | The division of u times a. |
Equality(Vector2, Vector2)
Check if the components of two vectors are equal.
Declaration
public static bool operator ==(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the two components are equal or false in any other case. |
Inequality(Vector2, Vector2)
Check if the components of two vectors are different.
Declaration
public static bool operator !=(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the two components are different or false in any other case. |
Multiply(Vector2, Vector2)
Multiplies two vectors component by component.
Declaration
public static Vector2 operator *(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| Vector2 | v | Vector2. |
Returns
| Type | Description |
|---|---|
| Vector2 | The multiplication of u times v. |
Multiply(Vector2, Double)
Multiplies a vector with an scalar.
Declaration
public static Vector2 operator *(Vector2 u, double a)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
| System.Double | a | Scalar. |
Returns
| Type | Description |
|---|---|
| Vector2 | The multiplication of u times a. |
Multiply(Double, Vector2)
Multiplies a scalar with a vector.
Declaration
public static Vector2 operator *(double a, Vector2 u)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | a | Scalar. |
| Vector2 | u | Vector3. |
Returns
| Type | Description |
|---|---|
| Vector2 | The multiplication of u times a. |
Subtraction(Vector2, Vector2)
Subtracts two vectors.
Declaration
public static Vector2 operator -(Vector2 u, Vector2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector3. |
| Vector2 | v | Vector3. |
Returns
| Type | Description |
|---|---|
| Vector2 | The subtraction of u minus v. |
UnaryNegation(Vector2)
Negates a vector.
Declaration
public static Vector2 operator -(Vector2 u)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | u | Vector2. |
Returns
| Type | Description |
|---|---|
| Vector2 | The negative vector of u. |