afVec3n.cpp
上传用户:kaiguan
上传日期:2007-10-28
资源大小:1074k
文件大小:1k
源码类别:

其他游戏

开发平台:

Visual C++

  1. #include "afVec3n.h"
  2. #include <math.h>
  3. #pragma warning(disable: 4514)
  4. afVec3n afVec3n::ORIGIN(0.0f,0.0f,0.0f);
  5. afVec3n afVec3n::FRONT(0.0f,0.0f,1.0f);
  6. afVec3n afVec3n::BACK(0.0f,0.0f,-1.0f);
  7. afVec3n afVec3n::LEFT(-1.0f,0.0f,0.0f);
  8. afVec3n afVec3n::RIGHT(1.0f,0.0f,0.0f);
  9. afVec3n afVec3n::UP(0.0f,1.0f,0.0f);
  10. afVec3n afVec3n::DOWN(0.0f,-1.0f,0.0f);
  11. void afVec3n::set(float nX, float nY, float nZ)
  12. {
  13. x=nX;
  14. y=nY;
  15. z=nZ;
  16. float l = length();
  17. if(l!=0.0f)
  18. {
  19. float il = 1.0f / l;
  20. x *= il;
  21. y *= il;
  22. z *= il;
  23. valid = true;
  24. }
  25. else
  26. valid = false;
  27. }
  28. const afVec3n& afVec3n::getDifferentVector() const
  29. {
  30. if(fabs(*this * afVec3n::LEFT)<0.99)
  31. return afVec3n::LEFT;
  32. else
  33. return afVec3n::DOWN;
  34. }