Vectors operations are similar to Matrix operations, but there is usually a need for faster calculations.  On one of my jobs in the 1980s we had to create a digital system that could do calculations very rapidly and with the power supply had to be lighter and smaller then a similar electrical analog computer that used differential voltages. It was a struggle, literally, the differential analog based calculations were more accurate and could take a mechanical beating, especially if an electro-magnetic pulse went off near by, although I never understood why since the EMP would generate weird voltages.  Eventually we were able to add more features and got a buy off of the design.  But for most of the history of humans, there were no digital computers, and there a lot of natural analog computers, there are no natural digital computers.

 

If you want to read more about ball and integrator (mechanical) or electrical analog computers see this paper:

And did I ever use an Electrical Analog Computer, why yes I did.  If you want to see this Class project:

 

How do you get the X and Y from a vector?

When use the DirectMath vectors, the output is always uses the four components, so a dot product has the four products repeated 4 times.  Now how do you pick off the X or Y component?  Here is how I do it, this is using the Visual Studio 11 beta, not the Express version, use a Blank project and then add a source.cpp .  Then paste the following into the source.cpp file, run it and you should get the command environment shown at the bottom of this blog.

//Tested on Windows 8 with VS 11 Beta
#include <iostream>
#include "DirectXMath.h"
using namespace DirectX; 
using namespace std;
 
ostream& operator<<(ostream& os, FXMVECTOR v)
{
     XMFLOAT4 dest;
     XMStoreFloat4(&dest, v);
     os << "(" << dest.x<< ", " << dest.y << ", " << dest.z <<  ", " << dest.w << ")";
     return os;
}
 
int main()
{
      //Loading the vectors with numbers
      XMVECTOR aVector = XMVectorSet(1.0f, 2.0f,3.0f,4.0f);
      XMVECTOR bVector = XMVectorSet(2.0f, 2.0f,1.0f,1.0f);
      //Multiply 2 vectors
      XMVECTOR Multiply2Vectors = XMVectorMultiply(aVector, bVector);
      //Output the vectors to be multiplied
      cout<<"aVector contains  "<< aVector <<endl;
      cout<<"bVector contains "<< bVector <<endl;
      //Multiply the 2 vectors and show the product or output
      cout << "aVector multiplied bVector = " <<  Multiply2Vectors << endl;
      //Get the X component of the vector
      cout << "aVector multiplied bVector X = " <<  XMVectorGetX(Multiply2Vectors) << endl;
      //Get the Y component of the vector
      cout << "aVector multiplied bVector Y = " <<  XMVectorGetY(Multiply2Vectors) << endl;
      system("PAUSE");
      return 0;
}

 

 

 

 

image