fsdf

//MessageBox(NULL,"sdf","df",NULL);

ballstate[i][j] = YES; 

 

 

 

double dx,dy;  

dx = b[j]->m_pt.x -b[i]->m_pt.x;  

dy = b[j]->m_pt.y -b[i]->m_pt.y;  

 

double ax,ay ;  

ax = dx/ dis;  

ay = dy / dis;  

         

speedVec pt1pt2;//两球连线向量  

pt1pt2.x = b[j]->m_pt.x -  b[i]->m_pt.x;

pt1pt2.y = b[j]->m_pt.y -  b[i]->m_pt.y;

         

         

speedVec pt1_pt2;//两球连线向量  

 

if( pt1pt2.y  == 0 && pt1pt2.x == 0)  

{  

}else if( pt1pt2.y  == 0 && pt1pt2.x != 0)  

{  

pt1_pt2.x = 1 ;  

pt1_pt2.y = 0;  

}else if( pt1pt2.x  == 0 && pt1pt2.y != 0)  

{  

pt1_pt2.x = 0 ;  

pt1_pt2.y = 1;  

}  

else if( pt1pt2.y  != 0 && pt1pt2.y  != 0 )  

{  

pt1_pt2.x = pt1pt2.x/dis ;  //法向量

pt1_pt2.y = pt1pt2.y/dis;  

}  

 

 

speedVec N1,N2;  

double temp31,temp32;  

temp31 = -( b[i]->m_V.x * pt1_pt2.x + b[i]->m_V.y * pt1_pt2.y) ;  

temp32 = -( b[j]->m_V.x * pt1_pt2.x + b[j]->m_V.y * pt1_pt2.y) ;  

N1.x = temp31* pt1_pt2.x ;  

N1.y = temp31* pt1_pt2.y ;  

N2.x = temp32* pt1_pt2.x ;  

N2.y =  temp32* pt1_pt2.y ;  

 

b[i]->m_newV.x =2*N2.x +  b[i]->m_V.x;  

b[i]->m_newV.y =2*N2.y + b[i]->m_V.y;  

b[j]->m_newV.x =2*N2.x +  b[j]->m_V.x;  

b[j]->m_newV.y =2*N2.y +  b[j]->m_V.y;  

你可能感兴趣的:(fsdf)