...ga ada yg bener nih ah jawabannya.
masalahnya dah tau di double precision sih dari awal.
cm ga tau solusinya.
casting ke int = solusi pertama, tp gagal kalo range Bu ama bv sangat random, ex: 1e-30,etc.
solusi kedua ga tau. nunggu ide.
solusi ketiga, jgn pake c++, pake matlab. sayangnya req pake c++.
int _tmain(int argc, _TCHAR* argv[])
{
double Bux = 1.444, Buy =2.3232, Buz =3.23232;
double bvx = -1.543, bvy = -2.5343, bvz = -3.5343;
double Bvx,Bvy,Bvz;
if((Bux*bvx+Buy*bvy+Buz*bvz)==0)
{
Bvx = bvx; Bvy = bvy; Bvz = bvz;
}
else
{
double k = -1 * (Bux*bvx+Buy*bvy+Buz*bvz) / (pow(Bux,2)+pow(Buy,2)+pow(Buz,2));
Bvx = (k*Bux)+bvx;
Bvy = (k*Buy)+bvy;
Bvz = (k*Buz)+bvz;
double dot_product = Bux*Bvx+Buy*Bvy+Buz*Bvz;
//kenapa dot_product harus nol
//dot_product = Bux * ((k*Bux)+bvx) + Buy*((k*Buy)+bvx)+ Buz*((k*Buz)+bvz)
// = k (Bux^2+Buy^2+Buz^2) + (Bux*bvx+Buy*bvy+Buz*bvz)
//masukin k = -1 * (Bux*bvx+Buy*bvy+Buz*bvz) / (pow(Bux,2)+pow(Buy,2)+pow(Buz,2))
// = 0
double g =3;
}
return 0;
}