Struct Vector
Represents a displacement in 2D space.
Implements
Inherited Members
Namespace: GraphShape
Assembly: GraphShape.dll
Syntax
[Serializable]
public struct Vector : IEquatable<Vector>
Constructors
| Improve this Doc View SourceVector(Double, Double)
Constructor.
Declaration
public Vector(double x, double y)
Parameters
Type | Name | Description |
---|---|---|
System.Double | x | X component value. |
System.Double | y | Y component value. |
Properties
| Improve this Doc View SourceLength
Gets the length of this vector.
Declaration
public readonly double Length { get; }
Property Value
Type | Description |
---|---|
System.Double | The length of this vector. |
LengthSquared
Gets the squared length of this vector.
Declaration
public readonly double LengthSquared { get; }
Property Value
Type | Description |
---|---|
System.Double | The squared length of this vector. |
X
X component value.
Declaration
public double X { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Y
Y component value.
Declaration
public double Y { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Methods
| Improve this Doc View SourceEquals(Vector)
Declaration
public bool Equals(Vector other)
Parameters
Type | Name | Description |
---|---|---|
Vector | other |
Returns
Type | Description |
---|---|
System.Boolean |
Equals(Vector, Vector)
Compares the two specified Vectors for equality.
Declaration
public static bool Equals(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | The first Vector to compare. |
Vector | vector2 | The second Vector to compare. |
Returns
Type | Description |
---|---|
System.Boolean | True if both Vector are equal, otherwise false. |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
Normalize()
Normalizes this vector.
Declaration
public void Normalize()
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Overrides
Operators
| Improve this Doc View SourceAddition(Vector, Vector)
Adds two vectors and returns the result as a vector.
Declaration
public static Vector operator +(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | The first vector to add. |
Vector | vector2 | The second vector to add. |
Returns
Type | Description |
---|---|
Vector | The sum of |
Division(Vector, Double)
Divides the specified vector by the specified scalar and returns the resulting vector.
Declaration
public static Vector operator /(Vector vector, double scalar)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | The vector to divide. |
System.Double | scalar | The scalar by which |
Returns
Type | Description |
---|---|
Vector | The result of dividing |
Equality(Vector, Vector)
Indicates whether both Vector are equal.
Declaration
public static bool operator ==(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | First Vector to compare. |
Vector | vector2 | Second Vector to compare. |
Returns
Type | Description |
---|---|
System.Boolean | True if both Vector are equal, otherwise false. |
Inequality(Vector, Vector)
Indicates whether both Vector are not equal.
Declaration
public static bool operator !=(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | First Vector to compare. |
Vector | vector2 | Second Vector to compare. |
Returns
Type | Description |
---|---|
System.Boolean | True if both Vector are equal, otherwise false. |
Multiply(Vector, Vector)
Calculates the dot product of the two specified vector structures and returns the result as a System.Double.
Declaration
public static double operator *(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | The first vector to multiply. |
Vector | vector2 | The second vector to multiply. |
Returns
Type | Description |
---|---|
System.Double | Returns a System.Double containing the scalar dot product of |
Multiply(Vector, Double)
Multiplies the specified vector by the specified scalar and returns the resulting vector.
Declaration
public static Vector operator *(Vector vector, double scalar)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | The vector to multiply. |
System.Double | scalar | The scalar to multiply. |
Returns
Type | Description |
---|---|
Vector | The result of multiplying |
Multiply(Double, Vector)
Multiplies the specified scalar by the specified vector and returns the resulting vector.
Declaration
public static Vector operator *(double scalar, Vector vector)
Parameters
Type | Name | Description |
---|---|---|
System.Double | scalar | The scalar to multiply. |
Vector | vector | The vector to multiply. |
Returns
Type | Description |
---|---|
Vector | The result of multiplying |
Subtraction(Vector, Vector)
Subtracts one specified vector from another.
Declaration
public static Vector operator -(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | The vector from which |
Vector | vector2 | The vector to subtract from |
Returns
Type | Description |
---|---|
Vector | The difference between |
UnaryNegation(Vector)
Negates the specified vector.
Declaration
public static Vector operator -(Vector vector)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | The vector to negate. |
Returns
Type | Description |
---|---|
Vector | A vector with X and Y values opposite of the X and Y values of |