00001
00021 #include <cmath>
00022 #include <iostream>
00023
00024 #include "popassert.h"
00025 #include "CVector3f.h"
00026 #include "CVectBase.h"
00027
00028
00029
00033 CVectBase::CVectBase() : m_ViewerPos(0,0,0), m_BoxPos(0,0,0)
00034 {
00035 m_Radius = -1;
00036 }
00037
00038
00042 CVectBase::CVectBase(const CVector3f& viewerpos,
00043 const CVector3f& boxpos,
00044 float radius, bool update) :
00045 m_ViewerPos(viewerpos), m_BoxPos(boxpos)
00046 {
00047
00048 m_Radius = radius;
00049
00050 if (update)
00051 Update();
00052 }
00053
00054
00067 void CVectBase::Update(void)
00068 {
00069
00070 m_B1 = m_BoxPos - m_ViewerPos;
00071
00072
00073 if (m_B1.x == 0 && m_B1.y == 0)
00074 {
00075 m_B3 = CVector3f(0, 1, 0);
00076 }
00077 else
00078 {
00079 m_B3 = CVector3f(0, 0, 1) - (CVector3f(0, 0, 1) >> m_B1);
00080 m_B3.Normalize();
00081 }
00082
00083
00084 m_B2 = m_B1 ^ m_B3;
00085 m_B2.Normalize();
00086 }
00087