1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-07-02 14:04:09 +00:00

3.14... -> math::pi<T>()

This commit is contained in:
bolero-MURAKAMI 2012-02-28 18:54:39 +09:00
parent 3078d76ceb
commit dacf1f40ac
3 changed files with 11 additions and 11 deletions

View file

@ -7,6 +7,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/tuple/tuple.hpp> #include <sprout/tuple/tuple.hpp>
#include <sprout/tuple/functions.hpp> #include <sprout/tuple/functions.hpp>
#include <sprout/math/constants.hpp>
#include <sprout/darkroom/access/access.hpp> #include <sprout/darkroom/access/access.hpp>
#include <sprout/darkroom/coords/vector.hpp> #include <sprout/darkroom/coords/vector.hpp>
#include <sprout/darkroom/rays/ray.hpp> #include <sprout/darkroom/rays/ray.hpp>
@ -52,8 +53,6 @@ namespace sprout {
SPROUT_STATIC_CONSTEXPR std::size_t point_of_intersection = 0; SPROUT_STATIC_CONSTEXPR std::size_t point_of_intersection = 0;
SPROUT_STATIC_CONSTEXPR std::size_t normal = 1; SPROUT_STATIC_CONSTEXPR std::size_t normal = 1;
}; };
private:
SPROUT_STATIC_CONSTEXPR unit_type pi = 3.1415926535897932384626433832795;
private: private:
position_type pos_; position_type pos_;
radius_type rad_; radius_type rad_;
@ -156,7 +155,7 @@ namespace sprout {
sprout::darkroom::coords::z(normal), sprout::darkroom::coords::z(normal),
sprout::darkroom::coords::x(normal) sprout::darkroom::coords::x(normal)
) )
/ pi / sprout::math::pi<unit_type>()
, ,
atan2( atan2(
sprout::darkroom::coords::y(normal), sprout::darkroom::coords::y(normal),
@ -165,7 +164,7 @@ namespace sprout {
+ sprout::darkroom::coords::z(normal) * sprout::darkroom::coords::z(normal) + sprout::darkroom::coords::z(normal) * sprout::darkroom::coords::z(normal)
) )
) )
/ (pi / 2) / sprout::math::pi_div_two<unit_type>()
) )
); );
} }

View file

@ -156,10 +156,7 @@ namespace sprout {
> >
{}; {};
} // namespace detail } // namespace detail
template< template<sprout::index_t I, std::size_t N>
sprout::index_t I,
std::size_t N
>
struct index_n struct index_n
: public sprout::detail::index_n_impl<I, N> : public sprout::detail::index_n_impl<I, N>
{}; {};

View file

@ -7,6 +7,7 @@
#include <istream> #include <istream>
#include <stdexcept> #include <stdexcept>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/math/constants.hpp>
#include <sprout/random/uniform_01.hpp> #include <sprout/random/uniform_01.hpp>
#include <sprout/random/random_result.hpp> #include <sprout/random/random_result.hpp>
@ -22,8 +23,6 @@ namespace sprout {
typedef RealType result_type; typedef RealType result_type;
private: private:
struct private_constructor_tag {}; struct private_constructor_tag {};
private:
SPROUT_STATIC_CONSTEXPR result_type pi = result_type(3.14159265358979323846);
private: private:
static SPROUT_CONSTEXPR bool arg_check_nothrow(RealType mean_arg, RealType sigma_arg) { static SPROUT_CONSTEXPR bool arg_check_nothrow(RealType mean_arg, RealType sigma_arg) {
return sigma_arg >= RealType(0); return sigma_arg >= RealType(0);
@ -125,7 +124,12 @@ namespace sprout {
using std::sin; using std::sin;
using std::cos; using std::cos;
return sprout::random::random_result<Engine, normal_distribution>( return sprout::random::random_result<Engine, normal_distribution>(
cached_rho * (valid ? cos(result_type(2) * pi * r1) : sin(result_type(2) * pi * r1)) * sigma_ + mean_, cached_rho
* (valid
? cos(result_type(2) * sprout::math::pi<result_type>() * r1)
: sin(result_type(2) * sprout::math::pi<result_type>() * r1)
)
* sigma_ + mean_,
eng, eng,
normal_distribution( normal_distribution(
mean_, mean_,