Kschuster
3 unresolved threads
3 unresolved threads
Merge request reports
Activity
- src/typed-geometry/functions/angle.hh 0 → 100644
5 #include <typed-geometry/functions/normal.hh> 6 #include <typed-geometry/functions/normalize.hh> 7 #include <typed-geometry/tests/vec_tests.hh> 8 #include <typed-geometry/types/angle.hh> 9 #include <typed-geometry/types/objects/triangle.hh> 10 #include <typed-geometry/types/vec.hh> 11 12 namespace tg 13 { 14 // returns the (smaller) angle between two vectors, i.e. the result is in 0..pi (0°..180°) 15 template <int D, class ScalarT> 16 TG_NODISCARD constexpr angle<fractional_result<ScalarT>> angle_between(vec<D, ScalarT> const& a, vec<D, ScalarT> const& b) 17 { 18 auto a_unit = normalize_safe(a); 19 auto b_unit = normalize_safe(b); 20 return acos(clamp(dot(a_unit, b_unit), fractional_result<ScalarT>(0), fractional_result<ScalarT>(1))); changed this line in version 2 of the diff
- src/typed-geometry/functions/angle.hh 0 → 100644
20 return acos(clamp(dot(a_unit, b_unit), fractional_result<ScalarT>(0), fractional_result<ScalarT>(1))); 21 } 22 23 // returns the angle between any two objects with unambiguous normals. The result is in 0..pi (0°..180°) 24 template <class A, class B> 25 TG_NODISCARD constexpr auto angle_between(A const& a, B const& b) -> decltype(acos(dot(normal(a), normal(b)))) 26 { 27 return acos(clamp(dot(normal(a), normal(b)), decltype(dot(normal(a), normal(b)))(0), decltype(dot(normal(a), normal(b)))(1))); 28 } 29 30 // Returns the angle of a rotation of a towards b about the orthogonal_axis 31 // The orthogonal axis is important to determine the direction of orientation (axb vs -axb) 32 template <class ScalarT> 33 TG_NODISCARD constexpr angle<fractional_result<ScalarT>> angle_towards(vec<3, ScalarT> const& a, vec<3, ScalarT> const& b, vec<3, ScalarT> const& orthogonal_axis) 34 { 35 TG_ASSERT(are_orthogonal(a, orthogonal_axis)); changed this line in version 3 of the diff
41 41 template <class T> 42 42 TG_NODISCARD constexpr mat<4, 4, T> rotation(angle<T> angle, dir<3, T> const& axis) changed this line in version 2 of the diff
added 1 commit
- 6619ac69 - proper rotation naming, saturate instead of clamp(...,0,1).
added 1 commit
- 46d27409 - Use TG_CONTRACT instead of asserts where reasonable.
mentioned in commit 37e1414e
Please register or sign in to reply