remove unnecessary method

This commit is contained in:
sillysagiri 2023-08-02 07:46:36 +07:00
parent afd46b5f07
commit ffd4b59eca
3 changed files with 32 additions and 1 deletions

View File

@ -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(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(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") 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"
"src/**/*.cpp" "src/**/*.cpp"
"${imgui_SOURCE_DIR}/*.cpp" "${imgui_SOURCE_DIR}/*.cpp"
"${imgui_SOURCE_DIR}/misc/cpp/*.cpp"
"${rlimgui_SOURCE_DIR}/*.cpp") "${rlimgui_SOURCE_DIR}/*.cpp")
set(PROJECT_INCLUDE set(PROJECT_INCLUDE

View File

@ -11,6 +11,7 @@
struct Texture; struct Texture;
struct RenderTexture; struct RenderTexture;
struct Color; struct Color;
struct Vector2;
namespace panda namespace panda
{ {
@ -49,4 +50,11 @@ namespace panda
// Utils // Utils
Random &GetDefaultRandom(); 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);
} }

22
src/utils/Distance.cpp Normal file
View File

@ -0,0 +1,22 @@
#include "core/Panda.hpp"
#include <cmath>
#include <raylib.h>
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);
}