* Fix previous commit

This commit is contained in:
Phillip Stephens 2015-08-31 14:27:09 -07:00
parent 716ca479ce
commit 394a225062
5 changed files with 61 additions and 1 deletions

19
include/CUnitVector.hpp Normal file
View File

@ -0,0 +1,19 @@
#ifndef CUNITVECTOR_HPP
#define CUNITVECTOR_HPP
#include "CVector3f.hpp"
class ZE_ALIGN(16) CUnitVector3f : public CVector3f
{
public:
ZE_DECLARE_ALIGNED_ALLOCATOR();
CUnitVector3f(const CVector3f& vec)
: CVector3f(vec)
{
if (canBeNormalized())
normalize();
}
};
#endif

View File

@ -215,7 +215,7 @@ class ZE_ALIGN(16) CVector2f
mag = 1.0 / mag;
return *this * mag;
}
return {1, 0};
return {0, 0};
}
inline float cross(const CVector2f& rhs) const

View File

@ -14,6 +14,7 @@
#include "CUnitVector.hpp"
#include "CRectangle.hpp"
#include "CPlane.hpp"
#include "CLine.hpp"
#include "CAABox.hpp"
#include "COBBox.hpp"
#include "CSphere.hpp"

10
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.0)
project(zeustest)
include_directories(../include)
add_executable(zeustest
main.cpp)
target_link_libraries(zeustest
Math)

30
test/main.cpp Normal file
View File

@ -0,0 +1,30 @@
#include <iostream>
#include <MathLib.hpp>
int main()
{
assert(!CAABox({100, 100, 100}, {100, 100, 100}).invalid());
assert(CAABox().invalid());
CVector3f vec{320, 632162.f, 800.f};
assert(vec.canBeNormalized());
assert(!vec.isZero());
assert(CVector3f().isZero());
assert(!vec.normalized().canBeNormalized());
float blarg = 5.f;
CVector3f t{100, 100, 200};
Math::clamp(blarg, 0.f, 1.f);
CAABox test{{-100, -100, -100}, {100, 100, 100}};
CAABox test2{{-100, -100, -100}, {100, 100, 100}};
CAABox test3{{-50, -50, -50}, {50, 50, 50}};
CAABox test4{{-50, -50, -105}, {50, 50, 105}};
CVector3f point(-90, 67, -105);
CVector3f closestPoint = test.closestPointAlongVector(point);
assert(t.isEqu(t));
assert(test.inside(test));
assert(test2.inside(test));
assert(test3.inside(test));
assert(!test4.inside(test));
return 0;
}