DirectX vectors and matrices

Source: Internet
Author: User

To configure the VC + + directory for vs2013 project properties:

For example, the DirectX SDK installation directory is the D:\Program Files (x86) \microsoft DirectX SDK (June 2010)

The Include directory and library directories are configured as follows:

/* Include */
$ (Vc_includepath); $ (Windowssdk_includepath);D: \program Files%28x86%29\microsoft DirectX SDK%28june 2010%29\include
/* Lib */
$ (vc_librarypath_x86); $ (windowssdk_librarypath_x86);D: \program Files%28x86%29\microsoft DirectX SDK%28june 2010%29 \lib\x86;$ (LibraryPath)

You can use LIB to add or use preprocessing Directives #pragma comment (Comment-type, ["commentstring"]) in the project properties-linker-input-additional dependencies.

1#include <d3dx10.h>2#include <iostream>3 using namespacestd;4 5 #pragmaComment (lib, "D3dx10.lib")6 7ostream&operator<< (ostream& OS, d3dxvector4&v)8 {9OS <<"("<< v.x <<", "<< v.y <<", "<< v.z <<", "<< V.W <<")";Ten     returnos; One } Aostream&operator<< (ostream& OS, d3dxmatrix&m) - { -      for(inti =0; I <4; ++i) the     { -          for(intj =0; J <4; ++j) -Os << m (i, J) <<"  "; -OS <<Endl; +     } -     returnos; + } Aostream&operator<< (ostream& OS, d3dxvector3&v) at { -OS <<"("<< v.x <<", "<< v.y <<", "<< v.z <<")"; -     returnos; - } -  - intMain () in { -     //Using Constructor, D3dxvector3 (float x, float y, float z); toD3dxvector3 U (1.0f,2.0f,3.0f); +  -     //Using Constructor, D3dxvector3 (CONST FLOAT *); the     floatx[3] = { -2.0f,1.0f, -3.0f }; * D3dxvector3 v (x); $ Panax Notoginseng     //Using Constructor, D3dxvector3 () {}; - D3dxvector3 A, B, C, D, E; the  +     //Vector Addition:d3dxvector3 operator + AA = U +v; the  +     //Vector Subtraction:d3dxvector3 operator- -b = U-v; $  $     //Scalar Multiplication:d3dxvector3 operator * -c = u *Ten; -  the     // || u| | -     floatL = D3dxvec3length (&u);Wuyi  the     //d = u/| | u| | -D3dxvec3normalize (&d, &u); Wu  -     //s = u dot v About     floats = D3dxvec3dot (&u, &v); $  -     //e = u x v -D3dxvec3cross (&e, &u, &v); -  Acout <<"u ="<< u <<Endl; +cout <<"v ="<< v <<Endl; thecout <<"a = U + V ="<< a <<Endl; -cout <<"b = u-v ="<< b <<Endl; $cout <<"c = u * Ten ="<< C <<Endl; thecout <<"d = u/| | u| | = "<< D <<Endl; thecout <<"e = u x v ="<< e <<Endl; thecout <<"L = | |     u| | = "<< L <<Endl; thecout <<"s = U.V ="<< s <<Endl; -cout <<Endl; in  the  the  AboutD3dxmatrix A (1.0f,0.0f,0.0f,0.0f, the                 0.0f,2.0f,0.0f,0.0f, the                 0.0f,0.0f,4.0f,0.0f, the                 1.0f,2.0f,3.0f,1.0f); +  - D3dxmatrix B; theD3DXMatrixIdentity (&B);Bayi  the     //Matrix-matrix Multiplication theD3dxmatrix C = A *B; -  - D3dxmatrix D, E, F; the  theD3dxmatrixtranspose (&d, &A); the  theD3dxmatrixinverse (&e,0, &A); -  theF = A *E; the  theD3dxvector4 P (2.0f,2.0f,2.0f,1.0f);94D3dxvector4 Q (2.0f,2.0f,2.0f,0.0f); the D3dxvector4 R, S; the  theD3dxvec4transform (&r, &p, &A);98  AboutD3dxvec4transform (&s, &q, &A); - 101cout <<"A ="<< Endl << A <<Endl;102cout <<"B ="<< Endl << B <<Endl;103cout <<"C = A*b ="<< Endl << C <<Endl;104cout <<"D = Transpose (A) ="<< Endl << D <<Endl; thecout <<"E = Inverse (A) ="<< Endl << E <<Endl;106cout <<"F = A*e ="<< Endl << F <<Endl;107cout <<"P ="<< P <<Endl;108cout <<"Q ="<< Q <<Endl;109cout <<"R = P*a ="<< R <<Endl; thecout <<"S = Q*a ="<< S <<Endl;111  the     return 0;113}

DirectX vectors and matrices

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.