Added unittest for vector cross product
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@754 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
#include "unittests_trimesh_garbage_collection.hh"
|
#include "unittests_trimesh_garbage_collection.hh"
|
||||||
#include "unittests_randomNumberGenerator.hh"
|
#include "unittests_randomNumberGenerator.hh"
|
||||||
#include "unittests_split_copy.hh"
|
#include "unittests_split_copy.hh"
|
||||||
|
#include "unittests_vector_type.hh"
|
||||||
|
|
||||||
int main(int _argc, char** _argv) {
|
int main(int _argc, char** _argv) {
|
||||||
|
|
||||||
|
|||||||
62
src/Unittests/unittests_vector_type.hh
Normal file
62
src/Unittests/unittests_vector_type.hh
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
#ifndef INCLUDE_UNITTESTS_OpenMeshVectorTest_HH
|
||||||
|
#define INCLUDE_UNITTESTS_OpenMeshVectorTest_HH
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <Unittests/unittests_common.hh>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
class OpenMeshVectorTest : public testing::Test {
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// This function is called before each test is run
|
||||||
|
virtual void SetUp() {
|
||||||
|
|
||||||
|
// Do some initial stuff with the member data here...
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function is called after all tests are through
|
||||||
|
virtual void TearDown() {
|
||||||
|
|
||||||
|
// Do some final stuff with the member data here...
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ====================================================================
|
||||||
|
* Define tests below
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Compute surface area via cross product
|
||||||
|
*/
|
||||||
|
TEST_F(OpenMeshVectorTest, ComputeTriangleSurfaceWithCrossProduct) {
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// vec1
|
||||||
|
// x
|
||||||
|
// |
|
||||||
|
// |
|
||||||
|
// |
|
||||||
|
// x------>x vec2
|
||||||
|
//
|
||||||
|
|
||||||
|
OpenMesh::Vec3d vec1(0.0,1.0,0.0);
|
||||||
|
OpenMesh::Vec3d vec2(1.0,0.0,0.0);
|
||||||
|
|
||||||
|
double area = 0.5 * cross(vec1,vec2).norm();
|
||||||
|
EXPECT_EQ(0.5f , area ) << "Wrong area in cross product function";
|
||||||
|
|
||||||
|
area = 0.5 * ( vec1 % vec2 ).norm();
|
||||||
|
EXPECT_EQ(0.5f , area ) << "Wrong area in cross product operator";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // INCLUDE GUARD
|
||||||
Reference in New Issue
Block a user