本文整理汇总了C++中calendar::year_turns方法的典型用法代码示例。如果您正苦于以下问题:C++ calendar::year_turns方法的具体用法?C++ calendar::year_turns怎么用?C++ calendar::year_turns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calendar
的用法示例。
在下文中一共展示了calendar::year_turns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_weather
w_point weather_generator::get_weather( const point &location, const calendar &t ) const
{
const double x( location.x /
2000.0 ); // Integer x position / widening factor of the Perlin function.
const double y( location.y /
2000.0 ); // Integer y position / widening factor of the Perlin function.
const double z( double( t.get_turn() + DAYS( t.season_length() ) ) /
2000.0 ); // Integer turn / widening factor of the Perlin function.
const double dayFraction( ( double )t.minutes_past_midnight() / 1440 );
//limit the random seed during noise calculation, a large value flattens the noise generator to zero
//Windows has a rand limit of 32768, other operating systems can have higher limits
const unsigned modSEED = SEED % 32768;
// Noise factors
double T( raw_noise_4d( x, y, z, modSEED ) * 4.0 );
double H( raw_noise_4d( x, y, z / 5, modSEED + 101 ) );
double H2( raw_noise_4d( x, y, z, modSEED + 151 ) / 4 );
double P( raw_noise_4d( x, y, z / 3, modSEED + 211 ) * 70 );
double W;
const double now( double( t.turn_of_year() + DAYS( t.season_length() ) / 2 ) / double(
t.year_turns() ) ); // [0,1)
const double ctn( cos( tau * now ) );
// Temperature variation
const double mod_t( 0 ); // TODO: make this depend on latitude and altitude?
const double current_t( base_t + mod_t ); // Current baseline temperature. Degrees Celsius.
const double seasonal_variation( ctn * -1 ); // Start and end at -1 going up to 1 in summer.
const double season_atenuation( ctn / 2 + 1 ); // Harsh winter nights, hot summers.
const double season_dispersion( pow( 2,
ctn + 1 ) - 2.3 ); // Make summers peak faster and winters not perma-frozen.
const double daily_variation( cos( tau * dayFraction - tau / 8 ) * -1 * season_atenuation / 2 +
season_dispersion * -1 ); // Day-night temperature variation.
T += current_t; // Add baseline to the noise.
T += seasonal_variation * 8 * exp( -pow( current_t * 2.7 / 10 - 0.5,
2 ) ); // Add season curve offset to account for the winter-summer difference in day-night difference.
T += daily_variation * 8 * exp( -pow( current_t / 30,
2 ) ); // Add daily variation scaled to the inverse of the current baseline. A very specific and finicky adjustment curve.
T = T * 9 / 5 + 32; // Convert to imperial. =|
// Humidity variation
const double mod_h( 0 );
const double current_h( base_h + mod_h );
H = std::max( std::min( ( ctn / 10.0 + ( -pow( H, 2 ) * 3 + H2 ) ) * current_h / 2.0 + current_h,
100.0 ),
0.0 ); // Humidity stays mostly at the mean level, but has low peaks rarely. It's a percentage.
// Pressure variation
P += seasonal_variation * 20 +
base_p; // Pressure is mostly random, but a bit higher on summer and lower on winter. In millibars.
// Wind power
W = std::max( 0, 1020 - ( int )P );
return w_point {T, H, P, W, false};
}
示例2: get_weather
w_point weather_generator::get_weather(const point &location, const calendar &t)
{
const double x(location.x / 2000.0);// Integer x position / widening factor of the Perlin function.
const double y(location.y / 2000.0);// Integer y position / widening factor of the Perlin function.
// Leaving these in just in case something ELSE goes wrong--KA101
// int initial_season(0);
// if(ACTIVE_WORLD_OPTIONS["INITIAL_SEASON"].getValue() == "spring") {
// initial_season = 1;
// } else if(ACTIVE_WORLD_OPTIONS["INITIAL_SEASON"].getValue() == "summer") {
// initial_season = 2;
// } else if(ACTIVE_WORLD_OPTIONS["INITIAL_SEASON"].getValue() == "autumn") {
// initial_season = 3;
// }
const double z( double( t.get_turn() + DAYS(t.season_length()) ) / 2000.0); // Integer turn / widening factor of the Perlin function.
const double dayFraction((double)t.minutes_past_midnight() / 1440);
// Noise factors
double T(raw_noise_4d(x, y, z, SEED) * 8.0);
double H(raw_noise_4d(x, y, z / 5, SEED + 101));
double H2(raw_noise_4d(x, y, z, SEED + 151) / 4);
double P(raw_noise_4d(x, y, z / 3, SEED + 211) * 70);
const double now( double( t.turn_of_year() + DAYS(t.season_length()) / 2 ) / double(t.year_turns()) ); // [0,1)
const double ctn(cos(tau * now));
// Temperature variation
const double mod_t(0); // TODO: make this depend on latitude and altitude?
const double current_t(base_t + mod_t); // Current baseline temperature. Degrees Celsius.
const double seasonal_variation(ctn * -1); // Start and end at -1 going up to 1 in summer.
const double season_atenuation(ctn / 2 + 1); // Harsh winter nights, hot summers.
const double season_dispersion(pow(2,
ctn * -1 + 1) - 2.3); // Make summers peak faster and winters not perma-frozen.
const double daily_variation(cos( tau * dayFraction - tau / 8 ) * -1 * season_atenuation +
season_dispersion); // Day-night temperature variation.
T += current_t; // Add baseline to the noise.
T += seasonal_variation * 12 * exp(-pow(current_t * 2.7 / 20 - 0.5,
2)); // Add season curve offset to account for the winter-summer difference in day-night difference.
T += daily_variation * 10 * exp(-pow(current_t / 30,
2)); // Add daily variation scaled to the inverse of the current baseline. A very specific and finicky adjustment curve.
T = T * 9 / 5 + 32; // Convert to imperial. =|
// Humidity variation
const double mod_h(0);
const double current_h(base_h + mod_h);
H = std::max(std::min((ctn / 10.0 + (-pow(H, 2) * 3 + H2)) * current_h / 2.0 + current_h, 100.0),
0.0); // Humidity stays mostly at the mean level, but has low peaks rarely. It's a percentage.
// Pressure variation
P += seasonal_variation * 20 +
base_p; // Pressure is mostly random, but a bit higher on summer and lower on winter. In millibars.
return w_point(T, H, P);
}