mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 00:53:34 +08:00
Added vector2.
This commit is contained in:
+19
-4
@@ -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()
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 : */
|
||||
Reference in New Issue
Block a user