Share via


Vector3 Structure

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Defines a vector with three components.

Namespace:  Microsoft.Xna.Framework
Assembly:  Microsoft.Xna.Framework.Math (in Microsoft.Xna.Framework.Math.dll)

Syntax

'Declaration
Public Structure Vector3
public struct Vector3

The Vector3 type exposes the following members.

Constructors

  Name Description
Public method Vector3(Single) Creates a new instance of Vector3.
Public method Vector3(Vector2, Single) Initializes a new instance of Vector3.
Public method Vector3(Single, Single, Single) Initializes a new instance of Vector3.

Top

Properties

  Name Description
Public propertyStatic member Backward Returns a unit Vector3 designating backward in a right-handed coordinate system (0, 0, 1).
Public propertyStatic member Down Returns a unit Vector3 designating down (0, −1, 0).
Public propertyStatic member Forward Returns a unit Vector3 designating forward in a right-handed coordinate system(0, 0, −1).
Public propertyStatic member Left Returns a unit Vector3 designating left (−1, 0, 0).
Public propertyStatic member One Returns a Vector3 with ones in all of its components.
Public propertyStatic member Right Returns a unit Vector3 pointing to the right (1, 0, 0).
Public propertyStatic member UnitX Returns the x unit Vector3 (1, 0, 0).
Public propertyStatic member UnitY Returns the y unit Vector3 (0, 1, 0).
Public propertyStatic member UnitZ Returns the z unit Vector3 (0, 0, 1).
Public propertyStatic member Up Returns a unit vector designating up (0, 1, 0).
Public propertyStatic member Zero Returns a Vector3 with all of its components set to zero.

Top

Methods

  Name Description
Public methodStatic member Add(Vector3, Vector3) Adds two vectors.
Public methodStatic member Add(Vector3%, Vector3%, Vector3%) Adds two vectors.
Public methodStatic member Barycentric(Vector3, Vector3, Vector3, Single, Single) Returns a Vector3 containing the 3D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 3D triangle.
Public methodStatic member Barycentric(Vector3%, Vector3%, Vector3%, Single, Single, Vector3%) Returns a Vector3 containing the 3D Cartesian coordinates of a point specified in barycentric (areal) coordinates relative to a 3D triangle.
Public methodStatic member CatmullRom(Vector3, Vector3, Vector3, Vector3, Single) Performs a Catmull-Rom interpolation using the specified positions.
Public methodStatic member CatmullRom(Vector3%, Vector3%, Vector3%, Vector3%, Single, Vector3%) Performs a Catmull-Rom interpolation using the specified positions.
Public methodStatic member Clamp(Vector3, Vector3, Vector3) Restricts a value to be within a specified range.
Public methodStatic member Clamp(Vector3%, Vector3%, Vector3%, Vector3%) Restricts a value to be within a specified range.
Public methodStatic member Cross(Vector3, Vector3) Calculates the cross product of two vectors.
Public methodStatic member Cross(Vector3%, Vector3%, Vector3%) Calculates the cross product of two vectors.
Public methodStatic member Distance(Vector3, Vector3) Calculates the distance between two vectors.
Public methodStatic member Distance(Vector3%, Vector3%, Single%) Calculates the distance between two vectors.
Public methodStatic member DistanceSquared(Vector3, Vector3) Calculates the distance between two vectors squared.
Public methodStatic member DistanceSquared(Vector3%, Vector3%, Single%) Calculates the distance between two vectors squared.
Public methodStatic member Divide(Vector3, Vector3) Divides the components of a vector by the components of another vector.
Public methodStatic member Divide(Vector3, Single) Divides a vector by a scalar value.
Public methodStatic member Divide(Vector3%, Vector3%, Vector3%) Divides the components of a vector by the components of another vector.
Public methodStatic member Divide(Vector3%, Single, Vector3%) Divides a vector by a scalar value.
Public methodStatic member Dot(Vector3, Vector3) Calculates the dot product of two vectors. If the two vectors are unit vectors, the dot product returns a floating point value between -1 and 1 that can be used to determine some properties of the angle between two vectors. For example, it can show whether the vectors are orthogonal, parallel, or have an acute or obtuse angle between them.
Public methodStatic member Dot(Vector3%, Vector3%, Single%) Calculates the dot product of two vectors and writes the result to a user-specified variable. If the two vectors are unit vectors, the dot product returns a floating point value between -1 and 1 that can be used to determine some properties of the angle between two vectors. For example, it can show whether the vectors are orthogonal, parallel, or have an acute or obtuse angle between them.
Public method Equals(Object) Returns a value that indicates whether the current instance is equal to a specified object. (Overrides ValueType.Equals(Object).)
Public method Equals(Vector3) Determines whether the specified Object is equal to the Vector3.
Public method GetHashCode Gets the hash code of the vector object. (Overrides ValueType.GetHashCode().)
Public methodStatic member Hermite(Vector3, Vector3, Vector3, Vector3, Single) Performs a Hermite spline interpolation.
Public methodStatic member Hermite(Vector3%, Vector3%, Vector3%, Vector3%, Single, Vector3%) Performs a Hermite spline interpolation.
Public method Length Calculates the length of the vector.
Public method LengthSquared Calculates the length of the vector squared.
Public methodStatic member Lerp(Vector3, Vector3, Single) Performs a linear interpolation between two vectors.
Public methodStatic member Lerp(Vector3%, Vector3%, Single, Vector3%) Performs a linear interpolation between two vectors.
Public methodStatic member Max(Vector3, Vector3) Returns a vector that contains the highest value from each matching pair of components.
Public methodStatic member Max(Vector3%, Vector3%, Vector3%) Returns a vector that contains the highest value from each matching pair of components.
Public methodStatic member Min(Vector3, Vector3) Returns a vector that contains the lowest value from each matching pair of components.
Public methodStatic member Min(Vector3%, Vector3%, Vector3%) Returns a vector that contains the lowest value from each matching pair of components.
Public methodStatic member Multiply(Vector3, Vector3) Multiplies the components of two vectors by each other.
Public methodStatic member Multiply(Vector3, Single) Multiplies a vector by a scalar value.
Public methodStatic member Multiply(Vector3%, Vector3%, Vector3%) Multiplies the components of two vectors by each other.
Public methodStatic member Multiply(Vector3%, Single, Vector3%) Multiplies a vector by a scalar value.
Public methodStatic member Negate(Vector3) Returns a vector pointing in the opposite direction.
Public methodStatic member Negate(Vector3%, Vector3%) Returns a vector pointing in the opposite direction.
Public method Normalize() Turns the current vector into a unit vector. The result is a vector one unit in length pointing in the same direction as the original vector.
Public methodStatic member Normalize(Vector3) Creates a unit vector from the specified vector. The result is a vector one unit in length pointing in the same direction as the original vector.
Public methodStatic member Normalize(Vector3%, Vector3%) Creates a unit vector from the specified vector, writing the result to a user-specified variable. The result is a vector one unit in length pointing in the same direction as the original vector.
Public methodStatic member Reflect(Vector3, Vector3) Returns the reflection of a vector off a surface that has the specified normal.
Public methodStatic member Reflect(Vector3%, Vector3%, Vector3%) Returns the reflection of a vector off a surface that has the specified normal.
Public methodStatic member SmoothStep(Vector3, Vector3, Single) Interpolates between two values using a cubic equation.
Public methodStatic member SmoothStep(Vector3%, Vector3%, Single, Vector3%) Interpolates between two values using a cubic equation.
Public methodStatic member Subtract(Vector3, Vector3) Subtracts a vector from a vector.
Public methodStatic member Subtract(Vector3%, Vector3%, Vector3%) Subtracts a vector from a vector.
Public method ToString Retrieves a string representation of the current object. (Overrides ValueType.ToString().)
Public methodStatic member Transform(Vector3, Matrix) Transforms a 3D vector by the given matrix.
Public methodStatic member Transform(Vector3, Quaternion) Transforms a Vector3 by a specified Quaternion rotation.
Public methodStatic member Transform(Vector3%, Matrix%, Vector3%) Transforms a Vector3 by the given Matrix.
Public methodStatic member Transform(Vector3%, Quaternion%, Vector3%) Transforms a Vector3 by a specified Quaternion rotation.
Public methodStatic member Transform(array<Vector3[], Matrix%, array<Vector3[]) Transforms a source array of Vector3s by a specified Matrix and writes the results to an existing destination array.
Public methodStatic member Transform(array<Vector3[], Quaternion%, array<Vector3[]) Transforms a source array of Vector3s by a specified Quaternion rotation and writes the results to an existing destination array.
Public methodStatic member Transform(array<Vector3[], Int32, Matrix%, array<Vector3[], Int32, Int32) Applies a specified transform Matrix to a specified range of an array of Vector3s and writes the results into a specified range of a destination array.
Public methodStatic member Transform(array<Vector3[], Int32, Quaternion%, array<Vector3[], Int32, Int32) Applies a specified Quaternion rotation to a specified range of an array of Vector3s and writes the results into a specified range of a destination array.
Public methodStatic member TransformNormal(Vector3, Matrix) Transforms a 3D vector normal by a matrix.
Public methodStatic member TransformNormal(Vector3%, Matrix%, Vector3%) Transforms a vector normal by a matrix.
Public methodStatic member TransformNormal(array<Vector3[], Matrix%, array<Vector3[]) Transforms an array of 3D vector normals by a specified Matrix.
Public methodStatic member TransformNormal(array<Vector3[], Int32, Matrix%, array<Vector3[], Int32, Int32) Transforms a specified range in an array of 3D vector normals by a specified Matrix and writes the results to a specified range in a destination array.

Top

Operators

  Name Description
Public operatorStatic member Addition Adds two vectors.
Public operatorStatic member Division(Vector3, Vector3) Divides the components of a vector by the components of another vector.
Public operatorStatic member Division(Vector3, Single) Divides a vector by a scalar value.
Public operatorStatic member Equality Tests vectors for equality.
Public operatorStatic member Inequality Tests vectors for inequality.
Public operatorStatic member Multiply(Single, Vector3) Multiplies a vector by a scalar value.
Public operatorStatic member Multiply(Vector3, Vector3) Multiplies the components of two vectors by each other.
Public operatorStatic member Multiply(Vector3, Single) Multiplies a vector by a scalar value.
Public operatorStatic member Subtraction Subtracts a vector from a vector.
Public operatorStatic member UnaryNegation Returns a vector pointing in the opposite direction.

Top

Fields

  Name Description
Public field X Gets or sets the x-component of the vector.
Public field Y Gets or sets the y-component of the vector.
Public field Z Gets or sets the z-component of the vector.

Top

Version Information

Silverlight

Supported in: 5

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.