Added Line, Vector, Point utility classes

This commit is contained in:
Tim Zeuner 2022-11-10 16:45:34 +01:00
parent 0e76610608
commit 035bcfb253
4 changed files with 99 additions and 1 deletions

View File

@ -15,6 +15,7 @@ include_directories( ${OpenCV_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/ControlModule
${CMAKE_CURRENT_SOURCE_DIR}/Interpreter
${CMAKE_CURRENT_SOURCE_DIR}/IntersectionHandler
${CMAKE_CURRENT_SOURCE_DIR}/Utils
)
link_directories( ${Input_SOURCE_DIRS}
@ -22,6 +23,7 @@ link_directories( ${Input_SOURCE_DIRS}
${ControlModule_SOURCE_DIRS}
${Interpreter_SOURCE_DIRS}
${IntersectionHandler_SOURCE_DIRS}
${Utils_SOURCE_DIRS}
)
add_subdirectory(Input)
@ -29,16 +31,18 @@ add_subdirectory(Processing)
add_subdirectory(ControlModule)
add_subdirectory(Interpreter)
add_subdirectory(IntersectionHandler)
add_subdirectory(Utils)
target_include_directories(Input PRIVATE .)
target_include_directories(Processing PRIVATE .)
target_include_directories(ControlModule PRIVATE .)
target_include_directories(Interpreter PRIVATE .)
target_include_directories(IntersectionHandler PRIVATE .)
target_include_directories(Utils PRIVATE .)
add_executable(lfr_image_processing lfr.cpp autonomous_mode_main.cpp)
target_link_libraries( lfr_image_processing ${OpenCV_LIBS} Input Processing ControlModule Interpreter IntersectionHandler Threads::Threads)
target_link_libraries( lfr_image_processing ${OpenCV_LIBS} Input Processing ControlModule Interpreter IntersectionHandler Utils Threads::Threads)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})

7
Utils/CMakeLists.txt Normal file
View File

@ -0,0 +1,7 @@
add_library(Utils utils.cpp)
set_target_properties(Utils PROPERTIES VERSION ${PROJECT_VERSION})
target_include_directories(Utils PRIVATE .)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

47
Utils/utils.cpp Normal file
View File

@ -0,0 +1,47 @@
#include "utils.h"
LFRPoint::LFRPoint(/* args */) : x(0.0), y(0.0)
{
}
LFRPoint::LFRPoint(double x, double y): x(x), y(y)
{
}
LFRPoint::~LFRPoint()
{
}
LFRVector::LFRVector(/* args */) : LFRPoint()
{
}
LFRVector::LFRVector(double x, double y) : LFRPoint(x, y)
{
}
LFRVector::LFRVector(const LFRPoint& pt) : LFRPoint(pt)
{
}
LFRVector::~LFRVector()
{
}
LFRLine::LFRLine(/* args */) : start(), dir()
{
}
LFRLine::LFRLine(LFRPoint start, LFRVector dir) : start(start), dir(dir)
{
}
LFRLine::LFRLine(LFRPoint start, LFRPoint end) : start(start)
{
dir = end - start;
}
LFRLine::~LFRLine()
{
}

40
Utils/utils.h Normal file
View File

@ -0,0 +1,40 @@
class LFRPoint
{
private:
/* data */
public:
double x, y;
LFRPoint(/* args */);
LFRPoint(double x, double y);
~LFRPoint();
LFRPoint operator-(const LFRPoint& pt){return LFRPoint(x-pt.x, y-pt.y);}
LFRPoint operator+(const LFRPoint& pt){return LFRPoint(x+pt.x, y+pt.y);}
};
class LFRVector : public LFRPoint
{
private:
/* data */
public:
LFRVector(/* args */);
LFRVector(double x, double y);
LFRVector(const LFRPoint& pt);
~LFRVector();
};
class LFRLine
{
private:
/* data */
public:
LFRPoint start;
LFRVector dir;
LFRLine(/* args */);
LFRLine(LFRPoint start, LFRVector dir);
LFRLine(LFRPoint start, LFRPoint end);
~LFRLine();
};