diff options
-rw-r--r-- | game/network/rail.cpp | 4 | ||||
-rw-r--r-- | test/test-maths.cpp | 4 | ||||
-rw-r--r-- | utility/maths.cpp | 6 | ||||
-rw-r--r-- | utility/maths.h | 2 |
4 files changed, 8 insertions, 8 deletions
diff --git a/game/network/rail.cpp b/game/network/rail.cpp index c926ced..7c045ad 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -80,7 +80,7 @@ round_sleepers(const float v) RailLinkStraight::RailLinkStraight(const NodePtr & a, const NodePtr & b) : RailLinkStraight(a, b, b->pos - a->pos) { } RailLinkStraight::RailLinkStraight(NodePtr a, NodePtr b, const glm::vec3 & diff) : - RailLink({std::move(a), flat_angle(diff)}, {std::move(b), flat_angle(-diff)}, glm::length(diff)) + RailLink({std::move(a), vector_yaw(diff)}, {std::move(b), vector_yaw(-diff)}, glm::length(diff)) { vertices.reserve(2 * railCrossSection.size()); indices.reserve(2 * railCrossSection.size()); @@ -102,7 +102,7 @@ RailLinkStraight::positionAt(float dist, unsigned char start) const const auto es {std::make_pair(ends[start].first.get(), ends[1 - start].first.get())}; const auto diff {es.second->pos - es.first->pos}; const auto dir {glm::normalize(diff)}; - return Transform {es.first->pos + dir * dist, {0, flat_angle(diff) /*, std::atan2(diff.x, -diff.z)*/, 0}}; + return Transform {es.first->pos + dir * dist, {0, vector_yaw(diff) /*, std::atan2(diff.x, -diff.z)*/, 0}}; } RailLinkCurve::RailLinkCurve(const NodePtr & a, const NodePtr & b, glm::vec2 c) : diff --git a/test/test-maths.cpp b/test/test-maths.cpp index aed51d0..ba1bc7b 100644 --- a/test/test-maths.cpp +++ b/test/test-maths.cpp @@ -8,13 +8,13 @@ constexpr auto quarter_pi = pi / 4.F; using vecter_to_angle = std::tuple<glm::vec3, float>; -BOOST_DATA_TEST_CASE(test_flat_angle, +BOOST_DATA_TEST_CASE(test_vector_yaw, boost::unit_test::data::make<vecter_to_angle>( {{north, 0}, {south, pi}, {west, half_pi}, {east, -half_pi}, {north + east, -quarter_pi}, {south + east, quarter_pi * -3}, {north + west, quarter_pi}, {south + west, quarter_pi * 3}}), v, a) { - BOOST_CHECK_CLOSE(flat_angle(v), a, 1.F); + BOOST_CHECK_CLOSE(vector_yaw(v), a, 1.F); } using normalize_angle = std::tuple<float, float>; diff --git a/utility/maths.cpp b/utility/maths.cpp index e36c91e..aa44220 100644 --- a/utility/maths.cpp +++ b/utility/maths.cpp @@ -16,7 +16,7 @@ flat_orientation(const glm::vec3 & diff) } float -flat_angle(const glm::vec3 & diff) +vector_yaw(const glm::vec3 & diff) { return std::atan2(diff.x, diff.z); } @@ -43,9 +43,9 @@ Arc::Arc(const glm::vec3 & centre3, const glm::vec3 & e0p, const glm::vec3 & e1p Arc([&]() -> Arc { const auto diffa = e0p - centre3; const auto diffb = e1p - centre3; - const auto anga = flat_angle(diffa); + const auto anga = vector_yaw(diffa); const auto angb = [&diffb, &anga]() { - const auto angb = flat_angle(diffb); + const auto angb = vector_yaw(diffb); return (angb < anga) ? angb + two_pi : angb; }(); return {anga, angb}; diff --git a/utility/maths.h b/utility/maths.h index 572268a..b8dd342 100644 --- a/utility/maths.h +++ b/utility/maths.h @@ -28,7 +28,7 @@ constexpr auto two_pi {glm::two_pi<float>()}; glm::mat4 flat_orientation(const glm::vec3 & diff); -float flat_angle(const glm::vec3 & diff); +float vector_yaw(const glm::vec3 & diff); float round_frac(const float & v, const float & frac); |