Show / Hide Table of Contents

Struct Vector

Represents a displacement in 2D space.

Implements
System.IEquatable<Vector>
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: GraphShape
Assembly: GraphShape.dll
Syntax
[Serializable]
public struct Vector : IEquatable<Vector>

Constructors

| Improve this Doc View Source

Vector(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 Source

Length

Gets the length of this vector.

Declaration
public readonly double Length { get; }
Property Value
Type Description
System.Double

The length of this vector.

| Improve this Doc View Source

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.

| Improve this Doc View Source

X

X component value.

Declaration
public double X { get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

Y

Y component value.

Declaration
public double Y { get; set; }
Property Value
Type Description
System.Double

Methods

| Improve this Doc View Source

Equals(Vector)

Declaration
public bool Equals(Vector other)
Parameters
Type Name Description
Vector other
Returns
Type Description
System.Boolean
| Improve this Doc View Source

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.

| Improve this Doc View Source

Equals(Object)

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.Boolean
Overrides
System.ValueType.Equals(System.Object)
| Improve this Doc View Source

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32
Overrides
System.ValueType.GetHashCode()
| Improve this Doc View Source

Normalize()

Normalizes this vector.

Declaration
public void Normalize()
| Improve this Doc View Source

ToString()

Declaration
public override string ToString()
Returns
Type Description
System.String
Overrides
System.ValueType.ToString()

Operators

| Improve this Doc View Source

Addition(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 vector1 and vector2.

| Improve this Doc View Source

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 vector will be divided.

Returns
Type Description
Vector

The result of dividing vector by scalar.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 vector1 and vector2, which is calculated using the following formula: vector1.X * vector2.X + vector1.Y * vector2.Y

| Improve this Doc View Source

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 vector and scalar.

| Improve this Doc View Source

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 scalar and vector.

| Improve this Doc View Source

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 vector2 is subtracted.

Vector vector2

The vector to subtract from vector1.

Returns
Type Description
Vector

The difference between vector1 and vector2.

| Improve this Doc View Source

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 vector.

Implements

System.IEquatable<T>

Extension Methods

GraphHelpers.GetDistances<TVertex, TEdge, TGraph>(TGraph)
GraphHelpers.GetDiameter<TVertex, TEdge, TGraph>(TGraph)
GraphHelpers.GetDiameter<TVertex, TEdge, TGraph>(TGraph, out Double[,])
  • Improve this Doc
  • View Source
In This Article
Back to top GraphShape