afVec3n.cpp
资源名称:AirForce.rar [点击查看]
上传用户:kaiguan
上传日期:2007-10-28
资源大小:1074k
文件大小:1k
源码类别:
其他游戏
开发平台:
Visual C++
- #include "afVec3n.h"
- #include <math.h>
- #pragma warning(disable: 4514)
- afVec3n afVec3n::ORIGIN(0.0f,0.0f,0.0f);
- afVec3n afVec3n::FRONT(0.0f,0.0f,1.0f);
- afVec3n afVec3n::BACK(0.0f,0.0f,-1.0f);
- afVec3n afVec3n::LEFT(-1.0f,0.0f,0.0f);
- afVec3n afVec3n::RIGHT(1.0f,0.0f,0.0f);
- afVec3n afVec3n::UP(0.0f,1.0f,0.0f);
- afVec3n afVec3n::DOWN(0.0f,-1.0f,0.0f);
- void afVec3n::set(float nX, float nY, float nZ)
- {
- x=nX;
- y=nY;
- z=nZ;
- float l = length();
- if(l!=0.0f)
- {
- float il = 1.0f / l;
- x *= il;
- y *= il;
- z *= il;
- valid = true;
- }
- else
- valid = false;
- }
- const afVec3n& afVec3n::getDifferentVector() const
- {
- if(fabs(*this * afVec3n::LEFT)<0.99)
- return afVec3n::LEFT;
- else
- return afVec3n::DOWN;
- }