Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

Vector3 Structure (Microsoft.DirectX)

How Do I...?

Describes and manipulates a vector in three-dimensional (3-D) space.

Definition

Visual BasicPublic Structure Vector3
C#public struct Vector3 
C++public value class Vector3 sealed 
JScriptIn JScript, you can use structures, but you cannot define your own.

Members Table

The following table lists the members exposed by the object.

Fields

FieldDescription
X Retrieves or sets the x component of a 3-D vector.
Y Retrieves or sets the y component of a 3-D vector.
Z Retrieves or sets the z component of a 3-D vector.

Methods

MethodDescription
Add Adds two 3-D vectors.
static (Shared in Visual Basic) BaryCentric Returns a point in barycentric coordinates, using specified 3-D vectors.
static (Shared in Visual Basic) CatmullRom Performs a Catmull-Rom interpolation using specified 3-D vectors.
static (Shared in Visual Basic) Cross Determines the cross product of two 3-D vectors.
static (Shared in Visual Basic) Dot Determines the dot product of two 3-D vectors.
Equals Returns a value that indicates whether the current instance is equal to a specified object.
GetHashCode Returns the hash code for the current instance.
static (Shared in Visual Basic) Hermite Performs a Hermite spline interpolation using the specified 3-D vectors.
Length Returns the length of a 3-D vector.
LengthSq Returns the square of the length of a 3-D vector.
static (Shared in Visual Basic) Lerp Performs a linear interpolation between two 3-D vectors.
Maximize Returns a 3-D vector that is made up of the largest components of two 3-D vectors.
Minimize Returns a 3-D vector that is made up of the smallest components of two 3-D vectors.
Multiply Multiplies a 3-D vector by a SingleLeave Site value.
Normalize Returns the normalized version of a 3-D vector.
static (Shared in Visual Basic) op_Addition Adds two vectors.
static (Shared in Visual Basic) op_Equality Compares the current instance of a class to another instance to determine whether they are the same.
static (Shared in Visual Basic) op_Inequality Compares the current instance of a class to another instance to determine whether they are different.
static (Shared in Visual Basic) op_Multiply Determines the product of a single value and a 3-D vector.
static (Shared in Visual Basic) op_Subtraction Subtracts two 3-D vectors.
static (Shared in Visual Basic) op_UnaryNegation Negates the vector.
Project Projects a vector from object space into screen space.
Scale Scales a 3-D vector.
Subtract Subtracts two 3-D vectors.
ToString Obtains a string representation of the current instance.
static (Shared in Visual Basic) Transform Transforms a 3-D vector or an array of 3-D vectors by a given matrix.
TransformCoordinate Transforms a 3-D vector or an array of 3-D vectors by a given matrix, projecting the result back into w = 1.
TransformNormal Transforms a 3-D vector normal by the given matrix.
Unproject Projects a vector from screen space into object space.
Vector3 Initializes a new instance of the Vector3 class.

Properties

PropertyDescription
static (Shared in Visual Basic) Empty Retrieves an empty 3-D vector.

How Do I...?

Set Up a View Matrix

This example demonstrates how to initialize the view transformation matrix, which transforms world coordinates into camera or view space.

In the following C# code example, the vector components of the Vector3 structure form the arguments for the LookAtLH method, which builds a left-handed (LH) look-at matrix. The View transformation matrix is set to be equal to this look-at matrix.

The three input vectors represent the following, respectively:

  1. The eye point: [0, 3, -5].
  2. The camera look-at target: the origin [0, 0, 0].
  3. The current world's up-direction: usually [0, 1, 0].

              [C#]
              
using Microsoft.DirectX.Direct3D;

Device device = null;  // Create rendering device.

// Set up the view matrix. A view matrix can be defined given an eye point,
//   a point to view, and a direction for which way is up. Here, you set 
//   the eye five units back along the z-axis and up three units, view the
//   origin, and define "up" to be in the y-direction.

device.Transform.View = Microsoft.DirectX.Matrix.LookAtLH(
                            new Vector3(0.0f, 3.0f, -5.0f),
                            new Vector3(0.0f, 0.0f, 0.0f),
                            new Vector3(0.0f, 1.0f, 0.0f));

Structure Information

NamespaceMicrosoft.DirectX
AssemblyMicrosoft.DirectX (microsoft.directx.dll)
Strong NameMicrosoft.DirectX,  Version=1.0.900.0,  Culture=neutral,  PublicKeyToken=d3231b57b74a1492

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.