From d203b4018aeac29e384301b6d2f928f8a9ce2d55 Mon Sep 17 00:00:00 2001 From: Horror Proton <107091537+horror-proton@users.noreply.github.com> Date: Mon, 19 Aug 2024 16:24:15 +0800 Subject: [PATCH] temp --- .../include/Arknights-Tile-Pos/TileCalc2.hpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/3rdparty/include/Arknights-Tile-Pos/TileCalc2.hpp b/3rdparty/include/Arknights-Tile-Pos/TileCalc2.hpp index a6e0c6737ff..013c98d1265 100644 --- a/3rdparty/include/Arknights-Tile-Pos/TileCalc2.hpp +++ b/3rdparty/include/Arknights-Tile-Pos/TileCalc2.hpp @@ -35,18 +35,21 @@ inline vec3d camera_euler_angles_yxz(const Level& /*level*/, bool side = false) } inline matrix4x4 camera_matrix_from_trans( - const vec3d& pos, - const vec3d& euler, + [[maybe_unused]] const vec3d& pos, + [[maybe_unused]] const vec3d& euler, double ratio, double fov_2_y = 20 * degree, double far = 1000, double near = 0.3) { + /* const double cos_y = std::cos(euler[0]); const double sin_y = std::sin(euler[0]); const double cos_x = std::cos(euler[1]); const double sin_x = std::sin(euler[1]); + */ const double tan_f = std::tan(fov_2_y); + /* const matrix4x4 translate = { 1, 0, 0, -pos[0], // @@ -66,6 +69,7 @@ inline matrix4x4 camera_matrix_from_trans( 0, -sin_x, -cos_x, 0, // 0, 0, 0, 1, }; + */ const double elem1 = -(far + near) / (far - near); // unable to inline, MSVC bug? const double elem2 = -(far * near * 2) / (far - near); const matrix4x4 proj = matrix4x4 { @@ -77,16 +81,19 @@ inline matrix4x4 camera_matrix_from_trans( // clang-format on }; + /* return proj * matrixX * matrixY * translate; + */ + return proj; } inline cv::Point world_to_screen(const Level& level, const vec3d& world_pos, bool side, const vec3d& offset = {}) { - static constexpr double width = 1280; - static constexpr double height = 720; + static constexpr int width = 1280; + static constexpr int height = 720; const vec3d pos_cam = camera_pos(level, side, width, height) + offset; const vec3d euler = camera_euler_angles_yxz(level, side); - const matrix4x4 matrix = camera_matrix_from_trans(pos_cam, euler, height / width); + const matrix4x4 matrix = camera_matrix_from_trans(pos_cam, euler, static_cast(height) / width); auto result = matrix * cv::Point3d(world_pos); result = result / result(3); result = (result + cv::Vec4d::ones()) / 2.;