Point3D.Offset(Double, Double, Double) Method

Definition

Translates the Point3D structure by the specified amounts.

C#
public void Offset(double offsetX, double offsetY, double offsetZ);

Parameters

offsetX
Double

The amount to change the X coordinate of this Point3D structure.

offsetY
Double

The amount to change the Y coordinate of this Point3D structure.

offsetZ
Double

The amount to change the Z coordinate of this Point3D structure.

Examples

The following example shows how to offset a Point3D structure.

C#
// 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);

Remarks

This operation is equivalent to adding a Vector3D structure to a Point3D structure with the corresponding X, Y, and Z values.

Note that calling the Offset method will only have an effect if you can change the X, Y, and Z properties directly. 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. If you attempt to change X, Y, or Z on a property or indexer reference, a compiler error occurs. Similarly, calling Offset on the property or indexer will not change the underlying object. 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.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10