Vector Structure

 

Represents a displacement in 2-D space.

Namespace:   System.Windows
Assembly:  WindowsBase (in WindowsBase.dll)

[SerializableAttribute]
[TypeConverterAttribute(typeof(VectorConverter))]
public struct Vector : IFormattable

NameDescription
System_CAPS_pubmethodVector(Double, Double)

Initializes a new instance of the Vector structure.

NameDescription
System_CAPS_pubpropertyLength

Gets the length of this vector.

System_CAPS_pubpropertyLengthSquared

Gets the square of the length of this vector.

System_CAPS_pubpropertyX

Gets or sets the X component of this vector.

System_CAPS_pubpropertyY

Gets or sets the Y component of this vector.

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticAdd(Vector, Point)

Translates the specified point by the specified vector and returns the resulting point.

System_CAPS_pubmethodSystem_CAPS_staticAdd(Vector, Vector)

Adds two vectors and returns the result as a Vector structure.

System_CAPS_pubmethodSystem_CAPS_staticAngleBetween(Vector, Vector)

Retrieves the angle, expressed in degrees, between the two specified vectors.

System_CAPS_pubmethodSystem_CAPS_staticCrossProduct(Vector, Vector)

Calculates the cross product of two vectors.

System_CAPS_pubmethodSystem_CAPS_staticDeterminant(Vector, Vector)

Calculates the determinant of two vectors.

System_CAPS_pubmethodSystem_CAPS_staticDivide(Vector, Double)

Divides the specified vector by the specified scalar and returns the result as a Vector.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified Object is a Vector structure and, if it is, whether it has the same X and Y values as this vector.(Overrides ValueType.Equals(Object).)

System_CAPS_pubmethodEquals(Vector)

Compares two vectors for equality.

System_CAPS_pubmethodSystem_CAPS_staticEquals(Vector, Vector)

Compares the two specified vectors for equality.

System_CAPS_pubmethodGetHashCode()

Returns the hash code for this vector. (Overrides ValueType.GetHashCode().)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticMultiply(Double, Vector)

Multiplies the specified scalar by the specified vector and returns the resulting Vector.

System_CAPS_pubmethodSystem_CAPS_staticMultiply(Vector, Double)

Multiplies the specified vector by the specified scalar and returns the resulting Vector.

System_CAPS_pubmethodSystem_CAPS_staticMultiply(Vector, Matrix)

Transforms the coordinate space of the specified vector using the specified Matrix.

System_CAPS_pubmethodSystem_CAPS_staticMultiply(Vector, Vector)

Calculates the dot product of the two specified vectors and returns the result as a Double.

System_CAPS_pubmethodNegate()

Negates this vector. The vector has the same magnitude as before, but its direction is now opposite.

System_CAPS_pubmethodNormalize()

Normalizes this vector.

System_CAPS_pubmethodSystem_CAPS_staticParse(String)

Converts a string representation of a vector into the equivalent Vector structure.

System_CAPS_pubmethodSystem_CAPS_staticSubtract(Vector, Vector)

Subtracts the specified vector from another specified vector.

System_CAPS_pubmethodToString()

Returns the string representation of this Vector structure.(Overrides ValueType.ToString().)

System_CAPS_pubmethodToString(IFormatProvider)

Returns the string representation of this Vector structure with the specified formatting information.

NameDescription
System_CAPS_puboperatorSystem_CAPS_staticAddition(Vector, Point)

Translates a point by the specified vector and returns the resulting point.

System_CAPS_puboperatorSystem_CAPS_staticAddition(Vector, Vector)

Adds two vectors and returns the result as a vector.

System_CAPS_puboperatorSystem_CAPS_staticDivision(Vector, Double)

Divides the specified vector by the specified scalar and returns the resulting vector.

System_CAPS_puboperatorSystem_CAPS_staticEquality(Vector, Vector)

Compares two vectors for equality.

System_CAPS_puboperatorSystem_CAPS_staticExplicit(Vector to Point)

Creates a Point with the X and Y values of this vector.

System_CAPS_puboperatorSystem_CAPS_staticExplicit(Vector to Size)

Creates a Size from the offsets of this vector.

System_CAPS_puboperatorSystem_CAPS_staticInequality(Vector, Vector)

Compares two vectors for inequality.

System_CAPS_puboperatorSystem_CAPS_staticMultiply(Double, Vector)

Multiplies the specified scalar by the specified vector and returns the resulting vector.

System_CAPS_puboperatorSystem_CAPS_staticMultiply(Vector, Double)

Multiplies the specified vector by the specified scalar and returns the resulting vector.

System_CAPS_puboperatorSystem_CAPS_staticMultiply(Vector, Matrix)

Transforms the coordinate space of the specified vector using the specified Matrix.

System_CAPS_puboperatorSystem_CAPS_staticMultiply(Vector, Vector)

Calculates the dot product of the two specified vector structures and returns the result as a Double.

System_CAPS_puboperatorSystem_CAPS_staticSubtraction(Vector, Vector)

Subtracts one specified vector from another.

System_CAPS_puboperatorSystem_CAPS_staticUnaryNegation(Vector)

Negates the specified vector.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIFormattable.ToString(String, IFormatProvider)

This member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. For a description of this member, see ToString.

A Point represents a fixed position, but a Vector represents a direction and a magnitude (for example, velocity or acceleration). Thus, the endpoints of a line segment are points but their difference is a vector; that is, the direction and length of that line segment.

In XAML, the delimiter between the X and Y values of a Vector can be either a comma or a space.

Some cultures might use the comma character as the decimal delimiter instead of the period character. XAML processing for invariant culture defaults to en-US in most XAML processor implementations, and expects the period to be the decimal delimiter. You should avoid using the comma character as the decimal delimiter if specifying a Vector in XAML, because that will clash with the string type conversion of a Vector attribute value into the X and Y components.

<object property="x,y"/>
-or-
<object property="x y"/>

x

The vector's X component. For more information, see the X property.

y

The vector's Y component. For more information, see the Y property.

The following example shows how to add two Vector structures.

// Adds a Vector to a Vector using the overloaded + operator.  

Vector vector1 = new Vector(20, 30);
Vector vector2 = new Vector(45, 70);
Vector vectorResult = new Vector();


// vectorResult is equal to (65,100)
vectorResult = vector1 + vector2;

.NET Framework
Available since 3.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: