# Vector3D Struct

## Definition

Represents a displacement in 3-D space.

``public value class 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``````
Inheritance
Vector3D
Attributes
Implements

## Examples

This example shows how to subtract Vector3D structures using the overloaded subtraction (`-`) operator and the Vector3D static Subtract method.

The following code shows how to use the Vector3D subtraction methods. First, the Vector3D structures are instantiated. 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)
``````

## Remarks

### XAML Attribute Usage

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

### XAML Values

x
The X component of this Vector3D structure.

y
The Y component of this Vector3D structure.

z
The Z component of this Vector3D structure.

## Constructors

 Initializes a new instance of a Vector3D structure.

## Properties

 Gets the length of this Vector3D structure. Gets the square of the length of this Vector3D structure. Gets or sets the X component of this Vector3D structure. Gets or sets the Y component of this Vector3D structure. Gets or sets the Z component of this Vector3D structure.

## Methods

 Translates the specified Point3D structure by the specified Vector3D structure and returns the result as a Point3D structure. Adds two Vector3D structures and returns the result as a Vector3D structure. Retrieves the angle required to rotate the first specified Vector3D structure into the second specified Vector3D structure. Calculates the cross product of two Vector3D structures. Divides the specified Vector3D structure by the specified scalar and returns the result as a Vector3D. Calculates the dot product of two Vector3D structures. 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. Compares two Vector3D structures for equality. Compares two Vector3D structures for equality. Gets a hash code for this Vector3D structure. Multiplies the specified scalar by the specified Vector3D structure and returns the result as a Vector3D. Multiplies the specified Vector3D structure by the specified scalar and returns the result as a Vector3D. Transforms the coordinate space of the specified Vector3D structure using the specified Matrix3D structure. Negates a Vector3D structure. Normalizes the specified Vector3D structure. Converts a String representation of a 3-D vector into the equivalent Vector3D structure. Subtracts a Point3D structure from a Vector3D structure. Subtracts a Vector3D structure from a Vector3D structure. Creates a String representation of this Vector3D structure. Creates a String representation of this Vector3D structure.

## Operators

 Translates the specified Point3D structure by the specified Vector3D structure and returns the result as a Point3D structure. Adds two Vector3D structures and returns the result as a Vector3D structure. Divides the specified Vector3D structure by the specified scalar and returns the result as a Vector3D. Compares two Vector3D structures for equality. Converts a Vector3D structure into a Point3D structure. Converts a Vector3D structure into a Size3D. Compares two Vector3D structures for inequality. Multiplies the specified scalar by the specified Vector3D structure and returns the result as a Vector3D. Multiplies the specified Vector3D structure by the specified scalar and returns the result as a Vector3D. Transforms the coordinate space of the specified Vector3D structure using the specified Matrix3D structure. Subtracts a Point3D structure from a Vector3D structure. Subtracts a Vector3D structure from a Vector3D structure. Negates a Vector3D structure.

## Explicit Interface Implementations

 This member is part of the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly by your code. For a description of this member, see ToString(String, IFormatProvider).