mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
add quaternion adapt (hash, tuple)
This commit is contained in:
parent
35bd69d5d3
commit
37eea2c53d
35 changed files with 1941 additions and 974 deletions
46
sprout/math/quaternion/spherical.hpp
Normal file
46
sprout/math/quaternion/spherical.hpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
https://github.com/bolero-MURAKAMI/Sprout
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_MATH_QUATERNION_SPHERICAL_HPP
|
||||
#define SPROUT_MATH_QUATERNION_SPHERICAL_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/math/cos.hpp>
|
||||
#include <sprout/math/sin.hpp>
|
||||
#include <sprout/math/quaternion/quaternion.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace math {
|
||||
//
|
||||
// spherical
|
||||
//
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR sprout::math::quaternion<T>
|
||||
spherical_impl(T const& rho, T const& theta, T const& phi1, T const& phi2, T const& p1, T const& p2) {
|
||||
return rho * sprout::math::quaternion<T>(
|
||||
sprout::math::cos(theta) * (p2 * p1),
|
||||
sprout::math::sin(theta) * (p2 * p1),
|
||||
sprout::math::sin(phi1) * p2,
|
||||
sprout::math::sin(phi2)
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR sprout::math::quaternion<T>
|
||||
spherical(T const& rho, T const& theta, T const& phi1, T const& phi2) {
|
||||
return sprout::math::detail::spherical_impl(
|
||||
rho, theta, phi1, phi2,
|
||||
sprout::math::cos(phi1), sprout::math::cos(phi2)
|
||||
);
|
||||
}
|
||||
} // namespace math
|
||||
|
||||
using sprout::math::spherical;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_MATH_QUATERNION_SPHERICAL_HPP
|
Loading…
Add table
Add a link
Reference in a new issue