diff --git a/CMakeLists.txt b/CMakeLists.txt index 2619fa8..8a21cd2 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ project(${PROJECT_NAME} VERSION ${PROJECT_VERSION}) ############################################################## set(RAYLIB_DIR "/home/tuanpanda/Panda/04-WORKSPACE/00-PROGRAMMING/_Git Clone/raylib-4.5.0") -set(IMGUI_DIR "/home/tuanpanda/Panda/04-WORKSPACE/00-PROGRAMMING/_Git Clone/imgui-1.89.7") +set(IMGUI_DIR "/home/tuanpanda/Panda/04-WORKSPACE/00-PROGRAMMING/_Git Clone/imgui-docking") set(RLIMGUI_DIR "/home/tuanpanda/Panda/04-WORKSPACE/00-PROGRAMMING/_Git Clone/rlImGui") set(INIFILE_DIR "/home/tuanpanda/Panda/04-WORKSPACE/00-PROGRAMMING/_Git Clone/inifile-cpp") @@ -66,6 +66,7 @@ file(GLOB PROJECT_SOURCES CONFIGURE_DEPENDS "src/*.cpp" "src/**/*.cpp" "${imgui_SOURCE_DIR}/*.cpp" + "${imgui_SOURCE_DIR}/misc/cpp/*.cpp" "${rlimgui_SOURCE_DIR}/*.cpp") set(PROJECT_INCLUDE diff --git a/src/core/Panda.hpp b/src/core/Panda.hpp index 16cddfc..4e690b8 100755 --- a/src/core/Panda.hpp +++ b/src/core/Panda.hpp @@ -11,6 +11,7 @@ struct Texture; struct RenderTexture; struct Color; +struct Vector2; namespace panda { @@ -49,4 +50,11 @@ namespace panda // Utils Random &GetDefaultRandom(); + + // Euclidean Distance + double distance(const Vector2 &p1, const Vector2 &p2); + double distanceSqrt(const Vector2 &p1, const Vector2 &p2); + + // Manhattan Distance + double distanceManhattan(const Vector2 &p1, const Vector2 &p2); } diff --git a/src/utils/Distance.cpp b/src/utils/Distance.cpp new file mode 100644 index 0000000..d7f49ee --- /dev/null +++ b/src/utils/Distance.cpp @@ -0,0 +1,22 @@ +#include "core/Panda.hpp" +#include +#include + +double panda::distance(const Vector2 &p1, const Vector2 &p2) +{ + double dx = p1.x - p2.x; + double dy = p1.y - p2.y; + return dx * dx + dy * dy; +} + +double panda::distanceSqrt(const Vector2 &p1, const Vector2 &p2) +{ + double dx = p1.x - p2.x; + double dy = p1.y - p2.y; + return std::sqrt(dx * dx + dy * dy); +} + +double panda::distanceManhattan(const Vector2 &p1, const Vector2 &p2) +{ + return std::abs(p1.x - p2.x) + std::abs(p1.y - p2.y); +} \ No newline at end of file