My program is to calculate the Vector X product using the Direct X Header/ Library
Iv'e got it to work something is wrong with the output of the Vectors
#include "D3DXD9Vector.h"
usingnamespace std;
int main()
{
char name[20];
int menu;
cout<<"Welcome to enterprise calculation systems!\n";
cout<<"Please enter your login credientials:\n[]:";
cin>>name;
menu = Mmenu();
}
int Mmenu(void)
{
int input;
int exit_flag=0;
int points;
while(exit_flag == 0)
{
cout<<"Select what would you like to do?\n";
cout<<"1. to run the program\n";
cout<<"2. to view instructions on how it works\n";
cout<<"3. exit the simulation\n";
cin>>input;
system("CLS");
switch(input)
{
case 1:
points = Pointme();
system("CLS");
break;
case 2:
system("CLS");
cout<<"Instructions to run simulation:\n";
cout<<"First input the 3 numbers that make up a vector\n";
cout<<"Input the second batch\n";
cout<<"It will calculate the dot/cross product\n\n";
Sleep(2000);
system("CLS");
break;
case 3:
system("CLS");
cout<<"Closing Simulation";
exit_flag=1;
break;
default:
system("CLS");
cout<<"Press the correct keys please";
break;
}
}while(exit_flag = 0);
return 0;
}
int Pointme(void)
{
D3DXVECTOR3 *firer;
D3DXVECTOR3 *target;
D3DXVECTOR3 VecCal;
target = new D3DXVECTOR3;
firer = new D3DXVECTOR3;
target->z = 1.0f;
firer->z = 1.0f;
cout<<"Start by entering the points one by one"<<endl;
cout<<"Begin with V1.x"<<endl;
cin>>target->x;
system("CLS");
cout<<"Enter the next V1.y point"<<endl;
cin>>target->y;
system("CLS");
cout<<"Enter the firer's 3D coordinates"<<endl;
cout<<"Again start with the Firer X"<<endl;
cin>>firer->x;
system("CLS");
cout<<"Now the Firer Y value"<<endl;
cin>>firer->y;
system("CLS");
cout<<"Your previous entries were"<<"("<<target->x<<", "<<target->y<<", "<<target->z<<")"<<endl;
cout<<"Your second entry was"<<"("<<firer->x<<", "<<firer->y<<", "<<firer->z<<")"<<endl;
cout<<"Your X product is:"<<endl;
cout<<"("<<VecCal.x<<", "<<VecCal.y<<", "<<VecCal.z<<")"<<endl;
VecCal = TargetVector(target, firer);
Sleep(5000);
cout<<"Main Menu loading.."<<endl;
system("CLS");
return 0;
}
D3DXVECTOR3 TargetVector(D3DXVECTOR3 *target, D3DXVECTOR3 *firer)
{
D3DXVECTOR3 MVector;
D3DXVec3Subtract(&MVector, target, firer);
D3DXVec3Normalize(&MVector, &MVector);
return MVector;
}
bool checkme(void)
{
bool ischecked = true;
if (cin.fail())
{
cout<<"Sorry but that isn't a number so it isn't allowed."<< endl;
cin.clear();
cin.sync();
system("CLS");
ischecked = false;
}
return ischecked;
}
Testing: X = 1 Y = 1 , X = 1 ,Y = 1
Your X product is:
(-1.07374e+008, -1.07374e+008, -1.07374e+008)
Testing X = 4, Y = 4, X = 4, Y = 4
Your X product is:
(-1.07374e+008, -1.07374e+008, -1.07374e+008)
The value is supposed to show the X product that was calculated using the D3DXVECTOR3 Function