49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
#include <math.h>
|
|
|
|
#ifdef HAS_OPENCV3
|
|
#include <opencv2/core.hpp> //Any OPENCV3 code
|
|
#else
|
|
#include <opencv2/core/core.hpp> //Any Opencv2 code
|
|
#endif
|
|
using namespace cv;
|
|
#include <cxxtest/TestSuite.h>
|
|
|
|
#include "geometry.h"
|
|
|
|
class TestLine : public CxxTest::TestSuite
|
|
{
|
|
public:
|
|
void testBisector(void)
|
|
{
|
|
// x-y = 0
|
|
auto l = get_line(Point(0,0), Point(1,1));
|
|
TS_ASSERT_EQUALS(l(0), -l(1));
|
|
TS_ASSERT_EQUALS(l(2), 0);
|
|
}
|
|
|
|
void testBisectorNegative(void)
|
|
{
|
|
// x+y = 0
|
|
auto l = get_line(Point(0,0), Point(1,-1));
|
|
TS_ASSERT_EQUALS(l(0), l(1));
|
|
TS_ASSERT_EQUALS(l(2), 0);
|
|
}
|
|
|
|
void testConstant(void)
|
|
{
|
|
// y = 42
|
|
// 0x+1y-42=0
|
|
auto l = get_line(Point(0,42), Point(10,42));
|
|
TS_ASSERT_EQUALS(l(0), 0);
|
|
TS_ASSERT_EQUALS(l(2), -42*l(1));
|
|
}
|
|
|
|
void testVertical(void)
|
|
{
|
|
// x = 42
|
|
// 1x+0y-42=0
|
|
auto l = get_line(Point(42,0), Point(42,10));
|
|
TS_ASSERT_EQUALS(l(1), 0);
|
|
TS_ASSERT_EQUALS(l(2), -42*l(0));
|
|
}
|
|
};
|