Advertisement
Guest User

Untitled

a guest
Feb 6th, 2013
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. // In-place alternate
  2. // Efficiently concatenate a translation into the matrix
  3. static void VecMatrixTranslate_2(float *a, const float *pVec)
  4. {
  5. float cTmp[16];
  6.  
  7. cTmp[_M44(0,0)] = a[_M44(0,0)] ;
  8. cTmp[_M44(0,1)] = a[_M44(0,1)] ;
  9. cTmp[_M44(0,2)] = a[_M44(0,2)] ;
  10. cTmp[_M44(0,3)] = a[_M44(0,0)]* pVec[0] + a[_M44(0,1)]* pVec[1] + a[_M44(0,2)]* pVec[2] + a[_M44(0,3)] ;
  11. cTmp[_M44(1,0)] = a[_M44(1,0)] ;
  12. cTmp[_M44(1,1)] = a[_M44(1,1)] ;
  13. cTmp[_M44(1,2)] = a[_M44(1,2)] ;
  14. cTmp[_M44(1,3)] = a[_M44(1,0)]* pVec[0] + a[_M44(1,1)]* pVec[1] + a[_M44(1,2)]* pVec[2] + a[_M44(1,3)] ;
  15. cTmp[_M44(2,0)] = a[_M44(2,0)] ;
  16. cTmp[_M44(2,1)] = a[_M44(2,1)] ;
  17. cTmp[_M44(2,2)] = a[_M44(2,2)] ;
  18. cTmp[_M44(2,3)] = a[_M44(2,0)]* pVec[0] + a[_M44(2,1)]* pVec[1] + a[_M44(2,2)]* pVec[2] + a[_M44(2,3)] ;
  19. cTmp[_M44(3,0)] = a[_M44(3,0)] ;
  20. cTmp[_M44(3,1)] = + a[_M44(3,1)] ;
  21. cTmp[_M44(3,2)] = a[_M44(3,2)] ;
  22. cTmp[_M44(3,3)] = a[_M44(3,0)]* pVec[0] + a[_M44(3,1)]* pVec[1] + a[_M44(3,2)]* pVec[2] + a[_M44(3,3)] ;
  23.  
  24. memcpy(a, cTmp, sizeof(cTmp));
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement