Export (0) Print
Expand All

What are Vectors, Matrices, and Quaternions?

The XNA Framework Math Libraries are in the Microsoft.Xna.Framework namespace alongside a number of additional types that deal with the XNA Framework Application model.

Coordinate system

The XNA Framework uses a right-handed coordinate system, with the positive z-axis pointing toward the observer when the positive x-axis is pointing to the right, and the positive y-axis is pointing up.

Mathematical Constants and Scalar Manipulation

The XNA Framework provides the MathHelper Members class for manipulating scalar values and retrieving some common mathematical constants. This includes methods such as the ToDegrees and ToRadians utility methods for converting between degrees and radians.

Basic Geometric Types

The XNA Framework Math library has multiple basic geometric types for manipulating objects in 2D or 3D space. Each geometric type has a number of mathematical operations that are supported for the type.

Vectors

The XNA Framework provides the Vector2, Vector3, and Vector4 classes for representing and manipulating vectors. A vector typically is used to represent a direction and magnitude. In the XNA Framework, however, it also could be used to store a coordinate or other data type with the same storage requirements.

Each vector class has methods for performing standard vector operations such as:

Matrices

The XNA Framework provides the Matrix class for transformation of geometry. The Matrix class uses row major order to address matrices, which means that the row is specified before the column when describing an element of a two-dimensional matrix. The Matrix class provides methods for performing standard matrix operations such as calculating the determinate or inverse of a matrix. There also are helper methods for creating scale, rotation, and translation matrices.

Quaternions

The XNA Framework provides the Quaternion structure to calculate the efficient rotation of a vector by a specified angle.

Curves

The Curve class represents a hermite curve for interpolating varying positions at different times without having to explicitly define each position. The curve is defined by a collection of CurveKey points representing each varying position at different times. This class can be used not only for spatial motion, but also to represent any response that changes over time.

Bounding Volumes

The XNA Framework provides the BoundingBox, BoundingFrustum, BoundingSphere, Plane, and Ray classes for representing simplified versions of geometry for the purpose of efficient collision and hit testing. These classes have methods for checking for intersection and containment with each other.

Precision and Performance

The XNA Framework Math libraries are single-precision. This means that the primitives and operations contained in this library use 32-bit floating-point numbers to achieve a balance between precision and efficiency when performing large numbers of calculations.

A 32-bit floating-point number ranges from –3.402823e38> to +3.402823e38. The 32 bits store the sign, mantissa, and exponent of the number that yields seven digits of floating-point precision. Some numbers—for example π, 1/3, or the square root of two—can be approximated only with seven digits of precision, so be aware of rounding errors when using a binary representation of a floating-point number. For more information about single-precision numbers, see the documentation for the Single data type.

Community Additions

ADD
Show:
© 2014 Microsoft