From 632d6a45b1bef2c939313f433af38d0c7f91d8a0 Mon Sep 17 00:00:00 2001 From: Orange Date: Sun, 28 Jul 2024 17:06:55 +0300 Subject: [PATCH] minor improvements --- .gitignore | 3 ++- source/Vector3.cpp | 14 ++++++-------- tests/CMakeLists.txt | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 28c6c4b..98568e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /cmake-build/ -/.idea \ No newline at end of file +/.idea +/out diff --git a/source/Vector3.cpp b/source/Vector3.cpp index 5abdd04..e0a68f1 100644 --- a/source/Vector3.cpp +++ b/source/Vector3.cpp @@ -204,8 +204,8 @@ namespace omath return { - angles::RadiansToDegrees(asinf(delta.z / distance)), - angles::RadiansToDegrees(atan2f(delta.y, delta.x)), + angles::RadiansToDegrees(std::asin(delta.z / distance)), + angles::RadiansToDegrees(std::atan2(delta.y, delta.x)), 0.f }; } @@ -241,7 +241,8 @@ namespace omath Vector3 Vector3::Cross(const Vector3 &v) const { - return { + return + { y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x @@ -251,10 +252,7 @@ namespace omath Vector3 Vector3::Normalized() const { const float length = this->Length(); - if (length != 0) - { - return *this / length; - } - return *this; + + return length != 0 ? *this / length : *this; } } \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a73124c..3c09cbb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,7 +1,7 @@ enable_testing() project(unit-tests) - +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}") file(GLOB TEST_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) include(GoogleTest)