home *** CD-ROM | disk | FTP | other *** search
/ Introduction to 3D Game …ogramming with DirectX 12 / Introduction-to-3D-Game-Programming-with-DirectX-12.ISO / Code.Textures / Chapter 1 Vector Algebra / XMVECTOR / tol.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2016-03-02  |  948 b   |  37 lines

  1. /*
  2. #include <windows.h> // for XMVerifyCPUSupport
  3. #include <DirectXMath.h>
  4. #include <DirectXPackedVector.h>
  5. #include <iostream>
  6. using namespace std;
  7. using namespace DirectX;
  8. using namespace DirectX::PackedVector;
  9.  
  10. int main()
  11. {
  12.     cout.precision(8);
  13.  
  14.     // Check support for SSE2 (Pentium4, AMD K8, and above).
  15.     if (!XMVerifyCPUSupport())
  16.     {
  17.         cout << "directx math not supported" << endl;
  18.         return 0;
  19.     }
  20.  
  21.     XMVECTOR u = XMVectorSet(1.0f, 1.0f, 1.0f, 0.0f);
  22.     XMVECTOR n = XMVector3Normalize(u);
  23.  
  24.     float LU = XMVectorGetX(XMVector3Length(n));
  25.  
  26.     // Mathematically, the length should be 1.  Is it numerically?
  27.     cout << LU << endl;
  28.     if (LU == 1.0f)
  29.         cout << "Length 1" << endl;
  30.     else
  31.         cout << "Length not 1" << endl;
  32.  
  33.     // Raising 1 to any power should still be 1.  Is it?
  34.     float powLU = powf(LU, 1.0e6f);
  35.     cout << "LU^(10^6) = " << powLU << endl;
  36. }
  37. */