Point3D.Offset(Double, Double, Double) 方法

定义

Point3D 结构平移指定量。Translates the Point3D structure by the specified amounts.

public:
 void Offset(double offsetX, double offsetY, double offsetZ);
public void Offset (double offsetX, double offsetY, double offsetZ);
member this.Offset : double * double * double -> unit
Public Sub Offset (offsetX As Double, offsetY As Double, offsetZ As Double)

参数

offsetX
Double

对此 X 结构的 Point3D 坐标要更改的量。The amount to change the X coordinate of this Point3D structure.

offsetY
Double

对此 Y 结构的 Point3D 坐标要更改的量。The amount to change the Y coordinate of this Point3D structure.

offsetZ
Double

对此 Z 结构的 Point3D 坐标要更改的量。The amount to change the Z coordinate of this Point3D structure.

示例

下面的示例演示如何偏移Point3D结构。The following example shows how to offset a Point3D structure.

// Offsets the X, Y and Z values of a Point3D.

Point3D point1 = new Point3D(10, 5, 1);

point1.Offset(20, 30, 40);
// point1 is equal to (30, 35, 41)

// Note: This operation is equivalent to adding a point 
// to vector with the corresponding X,Y, Z values.

// Displaying Results
syntaxString = "point1.Offset(20, 30, 40);";
resultType = "Point3D";
operationString = "Offsetting a Point3D";
ShowResults(point1.ToString(), syntaxString, resultType, operationString);
' Offsets the X, Y and Z values of a Point3D.

Dim point1 As New Point3D(10, 5, 1)

point1.Offset(20, 30, 40)
' point1 is equal to (30, 35, 41)

' Note: This operation is equivalent to adding a point 
' to vector with the corresponding X,Y, Z values.

' Displaying Results
syntaxString = "point1.Offset(20, 30, 40)"
resultType = "Point3D"
operationString = "Offsetting a Point3D"
ShowResults(point1.ToString(), syntaxString, resultType, operationString)

注解

Vector3D操作等效于将结构添加Point3D到具有相应X的、 YZ值的结构。This operation is equivalent to adding a Vector3D structure to a Point3D structure with the corresponding X, Y, and Z values.

请注意, 仅Offset当可以直接X更改、和Z属性时, Y调用方法才会起作用。Note that calling the Offset method will only have an effect if you can change the X, Y, and Z properties directly. 由于Point3D是一个值类型, 因此, 如果使用Point3D属性或索引器引用对象, 则会获得对象的副本, 而不是对对象的引用。Because Point3D is a value type, if you reference a Point3D object by using a property or indexer, you get a copy of the object, not a reference to the object. 如果尝试对属性或X索引Y器引用Z更改、或, 则会发生编译器错误。If you attempt to change X, Y, or Z on a property or indexer reference, a compiler error occurs. 同样, 对Offset属性或索引器调用将不会更改基础对象。Similarly, calling Offset on the property or indexer will not change the underlying object. 如果要更改被引用为属性或索引Point3D器的的值, 请创建新Point3D的, 修改其字段Point3D , 然后将返回回属性或索引器。If you want to change the value of a Point3D that is referenced as a property or indexer, create a new Point3D, modify its fields, and then assign the Point3D back to the property or indexer.

适用于