Game Development Reference
In-Depth Information
We usually denote a vector in lowercase bold but sometimes in upper-
case bold as well. Examples of two-, three-, and four-dimensional
vectors, respectively: u =( u x , u y ), N =( N x , N y , N z ), c =( c x , c y , c z , c w ).
We now introduce four special 3D vectors, which are illustrated in
Figure 4. The first is called the zero vector and has zeros for all of its
components; it is denoted by a bold zero: 0 = (0, 0, 0). The next three
special vectors are referred to as the standard basis vectors for
3 .
These vectors, called the i , j , and k vectors, run along the x-, y-, and
z-axis of our coordinate system, respectively, and have a magnitude of
one: i = (1, 0, 0), j = (0, 1, 0), and k = (0, 0, 1).
Note:
A vector with a magnitude of one is called a unit vector .
Figure 4: The zero vector and the standard basis vectors
for
3
In the D3DX library, we can use the D3DXVECTOR3 class to represent a
vector in 3-space. Its class definition is:
typedef struct D3DXVECTOR3 : public D3DVECTOR {
public:
D3DXVECTOR3() {};
D3DXVECTOR3( CONST FLOAT * );
D3DXVECTOR3( CONST D3DVECTOR& );
D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z );
// casting
operator FLOAT* ();
operator CONST FLOAT* () const;
// assignment operators
D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& );
D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& );
D3DXVECTOR3& operator *= ( FLOAT );
D3DXVECTOR3& operator /= ( FLOAT );
// unary operators
D3DXVECTOR3 operator + () const;
D3DXVECTOR3 operator - () const;
// binary operators
D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const;
D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const;
D3DXVECTOR3 operator * ( FLOAT ) const;
D3DXVECTOR3 operator / ( FLOAT ) const;
Team-Fly ®
Search WWH ::




Custom Search