Vector.Addition 操作员
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将向量添加到点或其他向量。
重载
Addition(Vector, Vector) |
将两个向量相加并将结果以向量形式返回。 |
Addition(Vector, Point) |
按指定向量平移点,并返回结果点。 |
Addition(Vector, Vector)
将两个向量相加并将结果以向量形式返回。
public:
static System::Windows::Vector operator +(System::Windows::Vector vector1, System::Windows::Vector vector2);
public static System.Windows.Vector operator + (System.Windows.Vector vector1, System.Windows.Vector vector2);
static member ( + ) : System.Windows.Vector * System.Windows.Vector -> System.Windows.Vector
Public Shared Operator + (vector1 As Vector, vector2 As Vector) As Vector
参数
- vector1
- Vector
要相加的第一个向量。
- vector2
- Vector
要相加的第二个向量。
返回
vector1
与 vector2
的和。
示例
下面的示例演示如何使用此运算符 (+) 添加两 Vector 个 Vector结构并返回 。
private Vector overloadedAdditionOperatorExample1()
{
Vector vector1 = new Vector(20, 30);
Vector vector2 = new Vector(45, 70);
Vector vectorResult = new Vector();
// Add the two vectors together.
// vectorResult is equal to (65,100)
vectorResult = vector1 + vector2;
return vectorResult;
}
Private Function overloadedAdditionOperatorExample1() As Vector
Dim vector1 As New Vector(20, 30)
Dim vector2 As New Vector(45, 70)
Dim vectorResult As New Vector()
' Add the two vectors together.
' vectorResult is equal to (65,100)
vectorResult = vector1 + vector2
Return vectorResult
End Function
另请参阅
适用于
Addition(Vector, Point)
按指定向量平移点,并返回结果点。
public:
static System::Windows::Point operator +(System::Windows::Vector vector, System::Windows::Point point);
public static System.Windows.Point operator + (System.Windows.Vector vector, System.Windows.Point point);
static member ( + ) : System.Windows.Vector * System.Windows.Point -> System.Windows.Point
Public Shared Operator + (vector As Vector, point As Point) As Point
参数
- vector
- Vector
用于平移 point
的向量。
- point
- Point
要平移的点。
返回
按 point
平移 vector
的结果。
示例
下面的示例演示如何使用此运算符 (+) 将 结构转换为 PointVector 结构。
private Point overloadedAdditionOperatorExample2()
{
Point point1 = new Point(10, 5);
Vector vector1 = new Vector(20, 30);
Point pointResult = new Point();
// Add the point to the vector.
// pointResult is equal to (30,35).
pointResult = point1 + vector1;
return pointResult;
}
Private Function overloadedAdditionOperatorExample2() As Point
Dim point1 As New Point(10, 5)
Dim vector1 As New Vector(20, 30)
Dim pointResult As New Point()
' Add the point to the vector.
' pointResult is equal to (30,35).
pointResult = point1 + vector1
Return pointResult
End Function