Vector3D 结构

定义

表示三维空间中的位移。Represents a displacement in 3-D space.

public value class Vector3D : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.Media.Media3D.Vector3DConverter))]
public struct Vector3D : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.Media.Media3D.Vector3DConverter))]
[System.Serializable]
public struct Vector3D : IFormattable
type Vector3D = struct
    interface IFormattable
Public Structure Vector3D
Implements IFormattable
继承
Vector3D
属性
实现

示例

此示例演示如何使用重载减法(-)运算符和 Vector3D 静态 Subtract 方法减去 Vector3D 结构。This example shows how to subtract Vector3D structures using the overloaded subtraction (-) operator and the Vector3D static Subtract method.

下面的代码演示如何使用 Vector3D 减法方法。The following code shows how to use the Vector3D subtraction methods. 首先,实例化 Vector3D 结构。First, the Vector3D structures are instantiated. 使用重载的(-)运算符减去 Vector3D 的结构,然后使用静态 Subtract 方法对其进行减法运算。The Vector3D structures are subtracted using the overloaded (-) operator, and then they are subtracted using the static Subtract method.

// Subtracts two 3-D Vectors using the Subtract method and -

// Declaring vector1 and initializing x,y,z values
Vector3D vector1 = new Vector3D(20, 30, 40);

// Declaring vector2 without initializing x,y,z values
Vector3D vector2 = new Vector3D();

// Assigning values to vector2
vector2.X = 45;
vector2.Y = 70;
vector2.Z = 80;

// Subtracting vectors using overload - operator
Vector3D vectorResult1 = new Vector3D();
vectorResult1 = vector1 - vector2;
// vectorResult1 is equal to (-25, -40, -40)

// Subtracting vectors using static Subtract method
Vector3D vectorResult2 = new Vector3D();
vectorResult2 = Vector3D.Subtract(vector1, vector2);
// vector2 is equal to (-25, -40, -40)

注解

XAML 属性用法XAML Attribute Usage

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

XAML 值XAML Values

xx
Vector3D 结构的 X 组件。The X component of this Vector3D structure.

yy
Vector3D 结构的 Y 组件。The Y component of this Vector3D structure.

zz
Vector3D 结构的 Z 组件。The Z component of this Vector3D structure.

构造函数

Vector3D(Double, Double, Double)

初始化 Vector3D 结构的新实例。Initializes a new instance of a Vector3D structure.

属性

Length

获取此 Vector3D 结构的长度。Gets the length of this Vector3D structure.

LengthSquared

获取此 Vector3D 结构的长度的平方。Gets the square of the length of this Vector3D structure.

X

获取或设置此 X 结构的 Vector3D 组件。Gets or sets the X component of this Vector3D structure.

Y

获取或设置此 Vector3D 结构的 Y 组件。Gets or sets the Y component of this Vector3D structure.

Z

获取或设置此 Vector3D 结构的 Z 组件。Gets or sets the Z component of this Vector3D structure.

方法

Add(Vector3D, Point3D)

按指定的 Point3D 结构平移指定的 Vector3D 结构并以 Point3D 结构返回结果。Translates the specified Point3D structure by the specified Vector3D structure and returns the result as a Point3D structure.

Add(Vector3D, Vector3D)

添加两个 Vector3D 结构并以 Vector3D 结构返回结果。Adds two Vector3D structures and returns the result as a Vector3D structure.

AngleBetween(Vector3D, Vector3D)

检索将第一个指定的 Vector3D 结构旋转为第二个指定的 Vector3D 结构所需的角度。Retrieves the angle required to rotate the first specified Vector3D structure into the second specified Vector3D structure.

CrossProduct(Vector3D, Vector3D)

计算两个 Vector3D 结构的叉乘积。Calculates the cross product of two Vector3D structures.

Divide(Vector3D, Double)

将指定的 Vector3D 结构除以指定的标量,并以 Vector3D 的形式返回结果。Divides the specified Vector3D structure by the specified scalar and returns the result as a Vector3D.

DotProduct(Vector3D, Vector3D)

计算两个 Vector3D 结构的点积。Calculates the dot product of two Vector3D structures.

Equals(Object)

确定指定的对象是否为 Vector3D 结构,以及指定的 XYZObject 属性是否与此 X 结构的 YZVector3D 属性相等。Determines whether the specified object is a Vector3D structure and whether the X, Y, and Z properties of the specified Object are equal to the X, Y, and Z properties of this Vector3D structure.

Equals(Vector3D)

比较两个 Vector3D 结构是否相等。Compares two Vector3D structures for equality.

Equals(Vector3D, Vector3D)

比较两个 Vector3D 结构是否相等。Compares two Vector3D structures for equality.

GetHashCode()

获取此 Vector3D 结构的哈希代码。Gets a hash code for this Vector3D structure.

Multiply(Double, Vector3D)

将指定的标量乘以指定的 Vector3D 结构,并以 Vector3D 的形式返回结果。Multiplies the specified scalar by the specified Vector3D structure and returns the result as a Vector3D.

Multiply(Vector3D, Double)

将指定的 Vector3D 结构乘以指定的标量,并以 Vector3D 的形式返回结果。Multiplies the specified Vector3D structure by the specified scalar and returns the result as a Vector3D.

Multiply(Vector3D, Matrix3D)

使用指定的 Vector3D 结构转换指定的 Matrix3D 结构的坐标空间。Transforms the coordinate space of the specified Vector3D structure using the specified Matrix3D structure.

Negate()

Vector3D 结构求反。Negates a Vector3D structure.

Normalize()

规范化指定 Vector3D 结构。Normalizes the specified Vector3D structure.

Parse(String)

三维3-D向量的 String 表示形式转换为等效的 Vector3D 结构。Converts a String representation of a 三维3-D vector into the equivalent Vector3D structure.

Subtract(Vector3D, Point3D)

从一个 Point3D 结构中减去一个 Vector3D 结构。Subtracts a Point3D structure from a Vector3D structure.

Subtract(Vector3D, Vector3D)

从一个 Vector3D 结构中减去一个 Vector3D 结构。Subtracts a Vector3D structure from a Vector3D structure.

ToString()

创建此 String 结构的 Vector3D 表示形式。Creates a String representation of this Vector3D structure.

ToString(IFormatProvider)

创建此 String 结构的 Vector3D 表示形式。Creates a String representation of this Vector3D structure.

运算符

Addition(Vector3D, Point3D)

按指定的 Point3D 结构平移指定的 Vector3D 结构并以 Point3D 结构返回结果。Translates the specified Point3D structure by the specified Vector3D structure and returns the result as a Point3D structure.

Addition(Vector3D, Vector3D)

添加两个 Vector3D 结构并以 Vector3D 结构返回结果。Adds two Vector3D structures and returns the result as a Vector3D structure.

Division(Vector3D, Double)

将指定的 Vector3D 结构除以指定的标量,并以 Vector3D 的形式返回结果。Divides the specified Vector3D structure by the specified scalar and returns the result as a Vector3D.

Equality(Vector3D, Vector3D)

比较两个 Vector3D 结构是否相等。Compares two Vector3D structures for equality.

Explicit(Vector3D to Point3D)

Vector3D 结构变换为 Point3D 结构。Converts a Vector3D structure into a Point3D structure.

Explicit(Vector3D to Size3D)

Vector3D 结构转换为 Size3DConverts a Vector3D structure into a Size3D.

Inequality(Vector3D, Vector3D)

比较两个 Vector3D 结构是否不相等。Compares two Vector3D structures for inequality.

Multiply(Double, Vector3D)

将指定的标量乘以指定的 Vector3D 结构,并以 Vector3D 的形式返回结果。Multiplies the specified scalar by the specified Vector3D structure and returns the result as a Vector3D.

Multiply(Vector3D, Double)

将指定的 Vector3D 结构乘以指定的标量,并以 Vector3D 的形式返回结果。Multiplies the specified Vector3D structure by the specified scalar and returns the result as a Vector3D.

Multiply(Vector3D, Matrix3D)

使用指定的 Vector3D 结构转换指定的 Matrix3D 结构的坐标空间。Transforms the coordinate space of the specified Vector3D structure using the specified Matrix3D structure.

Subtraction(Vector3D, Point3D)

从一个 Point3D 结构中减去一个 Vector3D 结构。Subtracts a Point3D structure from a Vector3D structure.

Subtraction(Vector3D, Vector3D)

从一个 Vector3D 结构中减去一个 Vector3D 结构。Subtracts a Vector3D structure from a Vector3D structure.

UnaryNegation(Vector3D)

Vector3D 结构求反。Negates a Vector3D structure.

显式接口实现

IFormattable.ToString(String, IFormatProvider)

此成员是 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基础结构的一部分,但不应由您的代码直接使用。This member is part of the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly by your code. 有关此成员的说明,请参见 ToString(String, IFormatProvider)For a description of this member, see ToString(String, IFormatProvider).

适用于