# Vector 結構

## 定義

``public value class Vector : IFormattable``
``````[System.ComponentModel.TypeConverter(typeof(System.Windows.VectorConverter))]
[System.Serializable]
public struct Vector : IFormattable``````
``````type Vector = struct
interface IFormattable``````
``````Public Structure Vector
Implements IFormattable``````

Vector

## 範例

``````// 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;
``````
``````' Adds a Vector to a Vector using the overloaded + operator.

Dim vector1 As New Vector(20, 30)
Dim vector2 As New Vector(45, 70)
Dim vectorResult As New Vector()

' vectorResult is equal to (65,100)
vectorResult = vector1 + vector2
``````

## 備註

### XAML Attribute UsageXAML Attribute Usage

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

xx

yy

## 建構函式

 初始化 Vector 結構的新執行個體。Initializes a new instance of the Vector structure.

## 屬性

 取得這個向量的長度。Gets the length of this vector. 取得這個向量的長度平方。Gets the square of the length of this vector. 取得或設定這個向量的 X 元件。Gets or sets the X component of this vector. 取得或設定這個向量的 Y 元件。Gets or sets the Y component of this vector.

## 方法

 依指定的向量平移指定的點，並傳回產生的點。Translates the specified point by the specified vector and returns the resulting point. 將兩個向量相加，並傳回結果做為 Vector 結構。Adds two vectors and returns the result as a Vector structure. 擷取兩個所指定向量之間的角度 (以度數表示)。Retrieves the angle, expressed in degrees, between the two specified vectors. 計算兩個向量的叉積。Calculates the cross product of two vectors. 計算兩個向量的行列式。Calculates the determinant of two vectors. 將指定的向量除以指定的純量，並傳回結果做為 Vector。Divides the specified vector by the specified scalar and returns the result as a Vector. 判斷指定的 Object 是否為 Vector 結構，如果是，則它的 X 和 Y 值是否與這個向量相同。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. 比較兩個向量是否相等。Compares two vectors for equality. 比較兩個指定的向量是否相等。Compares the two specified vectors for equality. 傳回這個向量的雜湊程式碼。Returns the hash code for this vector. 將指定的純量乘以指定的向量，並傳回產生的 Vector。Multiplies the specified scalar by the specified vector and returns the resulting Vector. 將指定的向量乘以指定的純量，並傳回產生的 Vector。Multiplies the specified vector by the specified scalar and returns the resulting Vector. 使用指定的 Matrix 轉換所指定向量的座標空間。Transforms the coordinate space of the specified vector using the specified Matrix. 計算兩個所指定向量的點積，並傳回結果做為 Double。Calculates the dot product of the two specified vectors and returns the result as a Double. 將這個向量加上負號。Negates this vector. 向量的大小和之前一樣，但是現在方向相反。The vector has the same magnitude as before, but its direction is now opposite. 將這個向量標準化。Normalizes this vector. 將向量的字串表示轉換為對等的 Vector 結構。Converts a string representation of a vector into the equivalent Vector structure. 將指定的向量從另一個指定的向量減去。Subtracts the specified vector from another specified vector. 傳回這個 Vector 結構的字串表示。Returns the string representation of this Vector structure. 使用指定的格式資訊，傳回這個 Vector 結構的字串表示。Returns the string representation of this Vector structure with the specified formatting information.

## 運算子

 依指定的向量平移點，並傳回產生的點。Translates a point by the specified vector and returns the resulting point. 將兩個向量相加，並傳回結果做為向量。Adds two vectors and returns the result as a vector. 將指定的向量除以指定的純量，並傳回產生的向量。Divides the specified vector by the specified scalar and returns the resulting vector. 比較兩個向量是否相等。Compares two vectors for equality. 使用這個向量的 Point 和 X 值建立 Y。Creates a Point with the X and Y values of this vector. 從這個向量的位移建立 Size。Creates a Size from the offsets of this vector. 比較兩個向量是否不相等。Compares two vectors for inequality. 將指定的純量乘以指定的向量，並傳回產生的向量。Multiplies the specified scalar by the specified vector and returns the resulting vector. 將指定的向量乘以指定的純量，並傳回產生的向量。Multiplies the specified vector by the specified scalar and returns the resulting vector. 使用指定的 Matrix 轉換所指定向量的座標空間。Transforms the coordinate space of the specified vector using the specified Matrix. 計算兩個所指定向量結構的點積，並傳回結果做為 Double。Calculates the dot product of the two specified vector structures and returns the result as a Double. 將某個指定的向量減去另一個指定的向量。Subtracts one specified vector from another. 將指定的向量變換正負號。Negates the specified vector.

## 明確介面實作

 這個成員支援 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基礎結構，但是您不可以從程式碼直接使用它。This member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. 如需這個成員的說明，請參閱 ToString(String, IFormatProvider)。For a description of this member, see ToString(String, IFormatProvider).