Added vector2.

This commit is contained in:
jgoppert
2015-11-07 14:27:12 -05:00
parent ace2751715
commit 9b995e19f3
12 changed files with 160 additions and 45 deletions
+19 -4
View File
@@ -7,14 +7,29 @@ set(tests
matrixScalarMult
transpose
vector
vector2
vector3
attitude
filter
squareMatrix
)
foreach(test ${tests})
add_executable(${test}
${test}.cpp)
add_test(${test} ${test})
add_custom_target(test_build)
foreach(test_name ${tests})
add_executable(${test_name}
${test_name}.cpp)
add_test(test_${test_name} ${test_name})
add_dependencies(test_build ${test_name})
endforeach()
if (COVERAGE)
add_custom_target(coverage
COMMAND lcov --capture --directory . --output-file coverage.info
COMMAND genhtml coverage.info --output-directory out
COMMAND x-www-browser out/index.html
WORKING_DIRECTORY ${CMAKE_BUILD_DIR}
DEPENDS coveralls test_build
)
endif()
+6
View File
@@ -23,6 +23,12 @@ int main()
R2 *= A_I;
R2.print();
assert(R2 == I);
Matrix3f A2 = eye<float, 3>()*2;
Matrix3f B = A2.emult(A2);
Matrix3f B_check = eye<float, 3>()*4;
assert(B == B_check);
return 0;
}
+1
View File
@@ -15,6 +15,7 @@ int main()
assert(fabs(v1.norm() - 7.416198487095663f) < 1e-5);
Vector<float, 5> v2(data2);
assert(fabs(v1.dot(v2) - 130.0f) < 1e-5);
assert(fabs(v1*v2 - 130.0f) < 1e-5);
v2.normalize();
Vector<float, 5> v3(v2);
assert(v2 == v3);
+18
View File
@@ -0,0 +1,18 @@
#include <assert.h>
#include <stdio.h>
#include <matrix/math.hpp>
using namespace matrix;
template class Vector<float, 3>;
int main()
{
Vector2f a(1, 0);
Vector2f b(0, 1);
assert (fabs(a % b - 1.0f) < 1e-5);
return 0;
}
/* vim: set et fenc=utf-8 ff=unix sts=0 sw=4 ts=4 : */