diff --git a/src/ballistics.cpp b/src/ballistics.cpp index 5ce0d30d90014..497da61481779 100644 --- a/src/ballistics.cpp +++ b/src/ballistics.cpp @@ -244,14 +244,14 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg, const tri rad += ( one_in( 2 ) ? 1 : -1 ) * std::min( ARCMIN( aim.dispersion ), DEGREES( 30 ) ); // TODO: This should also represent the miss on z axis - const int offset = std::min( range, sqrtf( aim.missed_by_tiles ) ); + const int offset = std::min( range, std::sqrtf( aim.missed_by_tiles ) ); int new_range = no_overshoot ? range + rng( -offset, offset ) : rng( range - offset, proj_arg.range ); new_range = std::max( new_range, 1 ); - target.x = source.x + roll_remainder( new_range * cos( rad ) ); - target.y = source.y + roll_remainder( new_range * sin( rad ) ); + target.x = source.x + roll_remainder( new_range * std::cos( rad ) ); + target.y = source.y + roll_remainder( new_range * std::sin( rad ) ); if( target == source ) { target.x = source.x + sgn( dx ); diff --git a/src/bionics.cpp b/src/bionics.cpp index ef58a6505b2e5..6f1b590061ff1 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -449,7 +449,7 @@ bool Character::activate_bionic( int b, bool eff_only ) int humidity = get_local_humidity( weatherPoint.humidity, g->weather.weather, g->is_sheltered( g->u.pos() ) ); // thirst units = 5 mL - int water_available = lround( humidity * 3.0 / 100.0 ); + int water_available = std::lround( humidity * 3.0 / 100.0 ); if( water_available == 0 ) { bio.powered = false; add_msg_if_player( m_bad, _( "There is not enough humidity in the air for your %s to function." ), @@ -1520,7 +1520,7 @@ void Character::process_bionic( int b ) int humidity = get_local_humidity( weatherPoint.humidity, g->weather.weather, g->is_sheltered( g->u.pos() ) ); // in thirst units = 5 mL water - int water_available = lround( humidity * 3.0 / 100.0 ); + int water_available = std::lround( humidity * 3.0 / 100.0 ); // At 50% relative humidity or more, the player will draw 10 mL // At 16% relative humidity or less, the bionic will give up if( water_available == 0 ) { diff --git a/src/consumption.cpp b/src/consumption.cpp index 70ce57930213c..6d8778a2c2d7c 100644 --- a/src/consumption.cpp +++ b/src/consumption.cpp @@ -957,7 +957,7 @@ bool player::eat( item &food, bool force ) } if( has_active_bionic( bio_taste_blocker ) ) { - mod_power_level( units::from_kilojoule( -abs( food.get_comestible_fun() ) ) ); + mod_power_level( units::from_kilojoule( -std::abs( food.get_comestible_fun() ) ) ); } if( food.has_flag( flag_FUNGAL_VECTOR ) && !has_trait( trait_M_IMMUNE ) ) { diff --git a/src/debug.cpp b/src/debug.cpp index ab55431f7571c..d0e9f05f7b083 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -290,7 +290,7 @@ static time_info get_time() noexcept const auto current = localtime( &tt ); return time_info { current->tm_hour, current->tm_min, current->tm_sec, - static_cast( lround( tv.tv_usec / 1000.0 ) ) + static_cast( std::lround( tv.tv_usec / 1000.0 ) ) }; } #endif diff --git a/src/explosion.cpp b/src/explosion.cpp index ffe2af1e9263e..b88fc274303fc 100644 --- a/src/explosion.cpp +++ b/src/explosion.cpp @@ -136,7 +136,7 @@ static float mass_to_area( const float mass ) // Density of steel in g/cm^3 constexpr float steel_density = 7.85; float fragment_volume = ( mass / 1000.0 ) / steel_density; - float fragment_radius = cbrt( ( fragment_volume * 3.0 ) / ( 4.0 * M_PI ) ); + float fragment_radius = std::cbrt( ( fragment_volume * 3.0 ) / ( 4.0 * M_PI ) ); return fragment_radius * fragment_radius * M_PI; } diff --git a/src/game.cpp b/src/game.cpp index e513452de96ca..ff1e4cb7aa47c 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3596,7 +3596,7 @@ void game::draw_minimap() double slope = ( cursx != targ.x ) ? static_cast( targ.y - cursy ) / static_cast ( targ.x - cursx ) : 4; - if( cursx == targ.x || fabs( slope ) > 3.5 ) { // Vertical slope + if( cursx == targ.x || std::fabs( slope ) > 3.5 ) { // Vertical slope if( targ.y > cursy ) { mvwputch( w_minimap, point( 3, 6 ), c_red, "*" ); } else { @@ -3605,7 +3605,7 @@ void game::draw_minimap() } else { int arrowx = -1; int arrowy = -1; - if( fabs( slope ) >= 1. ) { // y diff is bigger! + if( std::fabs( slope ) >= 1. ) { // y diff is bigger! arrowy = ( targ.y > cursy ? 6 : 0 ); arrowx = static_cast( 3 + 3 * ( targ.y > cursy ? slope : ( 0 - slope ) ) ); if( arrowx < 0 ) { @@ -11100,7 +11100,7 @@ void game::perhaps_add_random_npc() const int npc_num = overmap_buffer.get_npcs_near_player( density_search_radius ).size(); if( npc_num > 0 ) { // 100%, 80%, 64%, 52%, 41%, 33%... - density *= powf( 0.8f, npc_num ); + density *= std::powf( 0.8f, npc_num ); } if( !x_in_y( density, 100 ) ) { diff --git a/src/item.cpp b/src/item.cpp index 65639e8495d4f..8d04ff2bcf584 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -1638,8 +1638,8 @@ void item::food_info( const item *food_item, std::vector &info, const double multiplier = g->u.vitamin_rate( v.first ) / 1_days * 100; const int min_value = min_nutr.get_vitamin( v.first ); const int max_value = v.second; - const int min_rda = lround( min_value * multiplier ); - const int max_rda = lround( max_value * multiplier ); + const int min_rda = std::lround( min_value * multiplier ); + const int max_rda = std::lround( max_value * multiplier ); const std::string format = min_rda == max_rda ? "%s (%i%%)" : "%s (%i-%i%%)"; return string_format( format, v.first->name(), min_value, max_value ); }; @@ -5170,7 +5170,7 @@ static int calc_hourly_rotpoints_at_temp( const int temp ) } else if( temp < dropoff ) { return ( temp - temperatures::freezing ) * dstep; } else { - return lround( 215.46 * std::pow( 2.0, static_cast( temp ) / 16.0 ) ); + return std::lround( 215.46 * std::pow( 2.0, static_cast( temp ) / 16.0 ) ); } } @@ -5271,7 +5271,7 @@ units::volume item::get_storage() const } units::volume storage = t->storage; float mod = get_clothing_mod_val( clothing_mod_type_storage ); - storage += lround( mod ) * units::legacy_volume_factor; + storage += std::lround( mod ) * units::legacy_volume_factor; return storage; } @@ -5590,7 +5590,7 @@ int item::bash_resist( bool to_self ) const resist /= mat_types.size(); } - return lround( ( resist * eff_thickness ) + mod ); + return std::lround( ( resist * eff_thickness ) + mod ); } int item::cut_resist( bool to_self ) const @@ -5619,7 +5619,7 @@ int item::cut_resist( bool to_self ) const resist /= mat_types.size(); } - return lround( ( resist * eff_thickness ) + mod ); + return std::lround( ( resist * eff_thickness ) + mod ); } #if defined(_MSC_VER) @@ -5663,7 +5663,7 @@ int item::acid_resist( bool to_self, int base_env_resist ) const resist *= env / 10.0f; } - return lround( resist + mod ); + return std::lround( resist + mod ); } int item::fire_resist( bool to_self, int base_env_resist ) const @@ -5694,7 +5694,7 @@ int item::fire_resist( bool to_self, int base_env_resist ) const resist *= env / 10.0f; } - return lround( resist + mod ); + return std::lround( resist + mod ); } int item::chip_resistance( bool worst ) const @@ -8128,8 +8128,8 @@ void item::set_item_specific_energy( const float new_specific_energy ) } else if( new_item_temperature < temp_to_kelvin( temperatures::cold ) ) { item_tags.insert( "COLD" ); } - temperature = lround( 100000 * new_item_temperature ); - specific_energy = lround( 100000 * new_specific_energy ); + temperature = std::lround( 100000 * new_item_temperature ); + specific_energy = std::lround( 100000 * new_specific_energy ); reset_temp_check(); } @@ -8163,8 +8163,8 @@ void item::set_item_temperature( float new_temperature ) float new_specific_energy = get_specific_energy_from_temperature( new_temperature ); float freeze_percentage = 0; - temperature = lround( 100000 * new_temperature ); - specific_energy = lround( 100000 * new_specific_energy ); + temperature = std::lround( 100000 * new_temperature ); + specific_energy = std::lround( 100000 * new_specific_energy ); const float completely_frozen_specific_energy = specific_heat_solid * freezing_temperature; // Energy that the item would have if it was completely solid at freezing temperature @@ -8933,8 +8933,8 @@ void item::calc_temp( const int temp, const float insulation, const time_point & } else if( new_item_temperature < temp_to_kelvin( temperatures::cold ) ) { item_tags.insert( "COLD" ); } - temperature = lround( 100000 * new_item_temperature ); - specific_energy = lround( 100000 * new_specific_energy ); + temperature = std::lround( 100000 * new_item_temperature ); + specific_energy = std::lround( 100000 * new_specific_energy ); last_temp_check = time; } @@ -8954,7 +8954,7 @@ void item::heat_up() // Set item temperature to 60 C (333.15 K, 122 F) // Also set the energy to match temperature = 333.15 * 100000; - specific_energy = lround( 100000 * get_specific_energy_from_temperature( 333.15 ) ); + specific_energy = std::lround( 100000 * get_specific_energy_from_temperature( 333.15 ) ); reset_temp_check(); } @@ -8968,7 +8968,7 @@ void item::cold_up() // Set item temperature to 3 C (276.15 K, 37.4 F) // Also set the energy to match temperature = 276.15 * 100000; - specific_energy = lround( 100000 * get_specific_energy_from_temperature( 276.15 ) ); + specific_energy = std::lround( 100000 * get_specific_energy_from_temperature( 276.15 ) ); reset_temp_check(); } diff --git a/src/lightmap.cpp b/src/lightmap.cpp index ff0217154601f..23e1f63639dbf 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -1421,15 +1421,15 @@ void map::apply_light_arc( const tripoint &p, int angle, float luminance, int wi if( trigdist ) { double fdist = ( ao * M_PI_2 ) / wangle; double orad = ( M_PI * ao / 180.0 ); - end.x = static_cast( p.x + ( static_cast( range ) - fdist * 2.0 ) * cos( + end.x = static_cast( p.x + ( static_cast( range ) - fdist * 2.0 ) * std::cos( rad + orad ) ); - end.y = static_cast( p.y + ( static_cast( range ) - fdist * 2.0 ) * sin( + end.y = static_cast( p.y + ( static_cast( range ) - fdist * 2.0 ) * std::sin( rad + orad ) ); apply_light_ray( lit, p, end, luminance ); - end.x = static_cast( p.x + ( static_cast( range ) - fdist * 2.0 ) * cos( + end.x = static_cast( p.x + ( static_cast( range ) - fdist * 2.0 ) * std::cos( rad - orad ) ); - end.y = static_cast( p.y + ( static_cast( range ) - fdist * 2.0 ) * sin( + end.y = static_cast( p.y + ( static_cast( range ) - fdist * 2.0 ) * std::sin( rad - orad ) ); apply_light_ray( lit, p, end, luminance ); } else { diff --git a/src/lightmap.h b/src/lightmap.h index 8df48f6273a52..6a16e3ee6379d 100644 --- a/src/lightmap.h +++ b/src/lightmap.h @@ -23,7 +23,7 @@ #define LIGHT_TRANSPARENCY_OPEN_AIR 0.038376418216 #define LIGHT_TRANSPARENCY_CLEAR 1 -#define LIGHT_RANGE(b) static_cast( -log(LIGHT_AMBIENT_LOW / static_cast(b)) * (1.0 / LIGHT_TRANSPARENCY_OPEN_AIR) ) +#define LIGHT_RANGE(b) static_cast( -std::log(LIGHT_AMBIENT_LOW / static_cast(b)) * (1.0 / LIGHT_TRANSPARENCY_OPEN_AIR) ) enum lit_level { LL_DARK = 0, diff --git a/src/line.cpp b/src/line.cpp index 2cf190cd00ae3..6dc9c1ae15231 100644 --- a/src/line.cpp +++ b/src/line.cpp @@ -606,16 +606,16 @@ rl_vec3d rl_vec3d::normalized() const rl_vec2d rl_vec2d::rotated( float angle ) const { return rl_vec2d( - x * cos( angle ) - y * sin( angle ), - x * sin( angle ) + y * cos( angle ) + x * std::cos( angle ) - y * std::sin( angle ), + x * std::sin( angle ) + y * std::cos( angle ) ); } rl_vec3d rl_vec3d::rotated( float angle ) const { return rl_vec3d( - x * cos( angle ) - y * sin( angle ), - x * sin( angle ) + y * cos( angle ) + x * std::cos( angle ) - y * std::sin( angle ), + x * std::sin( angle ) + y * std::cos( angle ) ); } @@ -754,8 +754,8 @@ void calc_ray_end( int angle, const int range, const tripoint &p, tripoint &out const double rad = DEGREES( angle ); out.z = p.z; if( trigdist ) { - out.x = p.x + range * cos( rad ); - out.y = p.y + range * sin( rad ); + out.x = p.x + range * std::cos( rad ); + out.y = p.y + range * std::sin( rad ); } else { int mult = 0; if( angle >= 135 && angle <= 315 ) { @@ -766,9 +766,9 @@ void calc_ray_end( int angle, const int range, const tripoint &p, tripoint &out if( angle <= 45 || ( 135 <= angle && angle <= 215 ) || 315 < angle ) { out.x = p.x + range * mult; - out.y = p.y + range * tan( rad ) * mult; + out.y = p.y + range * std::tan( rad ) * mult; } else { - out.x = p.x + range * 1 / tan( rad ) * mult; + out.x = p.x + range * 1 / std::tan( rad ) * mult; out.y = p.y + range * mult; } } diff --git a/src/line.h b/src/line.h index 724c0f7ade12e..e7134cd1b6982 100644 --- a/src/line.h +++ b/src/line.h @@ -32,7 +32,7 @@ constexpr double ARCMIN( double v ) inline double iso_tangent( double distance, double vertex ) { // we can use the cosine formula (a² = b² + c² - 2bc⋅cosθ) to calculate the tangent - return std::sqrt( 2 * std::pow( distance, 2 ) * ( 1 - cos( ARCMIN( vertex ) ) ) ); + return std::sqrt( 2 * std::pow( distance, 2 ) * ( 1 - std::cos( ARCMIN( vertex ) ) ) ); } //! This compile-time usable function combines the sign of each (x, y, z) component into a single integer diff --git a/src/map.cpp b/src/map.cpp index c31b7da76dee2..ce59663c1e4b9 100755 --- a/src/map.cpp +++ b/src/map.cpp @@ -553,7 +553,7 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint &dp, const tileray &fac int coll_turn = 0; if( impulse > 0 ) { coll_turn = shake_vehicle( veh, velocity_before, facing.dir() ); - const int volume = std::min( 100, sqrtf( impulse ) ); + const int volume = std::min( 100, std::sqrtf( impulse ) ); // TODO: Center the sound at weighted (by impulse) average of collisions sounds::sound( veh.global_pos3(), volume, sounds::sound_t::combat, _( "crash!" ), false, "smash_success", "hit_vehicle" ); diff --git a/src/melee.cpp b/src/melee.cpp index 432e626fefe68..73d093d30d681 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -2216,7 +2216,7 @@ double player::melee_value( const item &weap ) const float reach = weap.reach_range( *this ); if( reach > 1.0f ) { - my_value *= 1.0f + 0.5f * ( sqrtf( reach ) - 1.0f ); + my_value *= 1.0f + 0.5f * ( std::sqrtf( reach ) - 1.0f ); } add_msg( m_debug, "%s as melee: %.1f", weap.type->get_id(), my_value ); diff --git a/src/npc.cpp b/src/npc.cpp index 1bd1410d4fc20..2bcde461531ee 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -1368,8 +1368,8 @@ float npc::vehicle_danger( int radius ) const int ax = wrapped_veh.v->global_pos3().x; int ay = wrapped_veh.v->global_pos3().y; - int bx = int( ax + cos( facing * M_PI / 180.0 ) * radius ); - int by = int( ay + sin( facing * M_PI / 180.0 ) * radius ); + int bx = int( ax + std::cos( facing * M_PI / 180.0 ) * radius ); + int by = int( ay + std::sin( facing * M_PI / 180.0 ) * radius ); // fake size /* This will almost certainly give the wrong size/location on customized diff --git a/src/overmap_noise.cpp b/src/overmap_noise.cpp index 10ff4d9405333..36443c60c5937 100644 --- a/src/overmap_noise.cpp +++ b/src/overmap_noise.cpp @@ -11,10 +11,10 @@ float om_noise_layer_forest::noise_at( const point &local_omt_pos ) const { const point p = global_omt_pos( local_omt_pos ); float r = scaled_octave_noise_3d( 8, 0.5, 0.03, 0, 1, p.x, p.y, get_seed() ); - r = powf( r, 2 ); + r = std::powf( r, 2 ); float d = scaled_octave_noise_3d( 12, 0.5, 0.07, 0, 1, p.x, p.y, get_seed() ); - d = powf( d, 3 ); + d = std::powf( d, 3 ); return std::max( 0.0f, r - d * 0.5f ); } @@ -23,7 +23,7 @@ float om_noise_layer_floodplain::noise_at( const point &local_omt_pos ) const { const point p = global_omt_pos( local_omt_pos ); float r = scaled_octave_noise_3d( 8, 0.5, 0.05, 0, 1, p.x, p.y, get_seed() ); - r = powf( r, 2 ); + r = std::powf( r, 2 ); return r; } @@ -31,7 +31,7 @@ float om_noise_layer_lake::noise_at( const point &local_omt_pos ) const { const point p = global_omt_pos( local_omt_pos ); float r = scaled_octave_noise_3d( 16, 0.5, 0.002, 0, 1, p.x, p.y, get_seed() ); - r = powf( r, 4 ); + r = std::powf( r, 4 ); return r; } diff --git a/src/panels.cpp b/src/panels.cpp index ec5af2894d0a4..69db8574e7899 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -349,7 +349,7 @@ void overmap_ui::draw_overmap_chunk( const catacurses::window &w_minimap, const double slope = ( cursx != targ.x ) ? static_cast( targ.y - cursy ) / static_cast ( targ.x - cursx ) : 4; - if( cursx == targ.x || fabs( slope ) > 3.5 ) { // Vertical slope + if( cursx == targ.x || std::fabs( slope ) > 3.5 ) { // Vertical slope if( targ.y > cursy ) { mvwputch( w_minimap, point( 3 + start_x, 6 + start_y ), c_red, '*' ); } else { @@ -358,7 +358,7 @@ void overmap_ui::draw_overmap_chunk( const catacurses::window &w_minimap, const } else { int arrowx = -1; int arrowy = -1; - if( fabs( slope ) >= 1. ) { // y diff is bigger! + if( std::fabs( slope ) >= 1. ) { // y diff is bigger! arrowy = ( targ.y > cursy ? 6 : 0 ); arrowx = static_cast( 3 + 3 * ( targ.y > cursy ? slope : ( 0 - slope ) ) ); if( arrowx < 0 ) { @@ -850,9 +850,9 @@ static int get_int_digits( const int &digits ) { int temp = std::abs( digits ); if( digits > 0 ) { - return static_cast( log10( static_cast( temp ) ) ) + 1; + return static_cast( std::log10( static_cast( temp ) ) ) + 1; } else if( digits < 0 ) { - return static_cast( log10( static_cast( temp ) ) ) + 2; + return static_cast( std::log10( static_cast( temp ) ) ) + 2; } return 1; } diff --git a/src/player_display.cpp b/src/player_display.cpp index 057d3a411df5f..f5533d987ed75 100644 --- a/src/player_display.cpp +++ b/src/player_display.cpp @@ -300,7 +300,7 @@ static void draw_stats_tab( const catacurses::window &w_stats, const catacurses: string_format( _( "Melee to-hit bonus: %+.1lf" ), you.get_melee_hit_base() ) ); print_colored_text( w_info, point( 1, 4 ), col_temp, c_light_gray, string_format( _( "Ranged penalty: %+d" ), - -abs( you.ranged_dex_mod() ) ) ); + -std::abs( you.ranged_dex_mod() ) ) ); print_colored_text( w_info, point( 1, 5 ), col_temp, c_light_gray, string_format( _( "Throwing penalty per target's dodge: %+d" ), you.throw_dispersion_per_dodge( false ) ) ); diff --git a/src/ranged.cpp b/src/ranged.cpp index a3ca204437490..9008e6cb2aadf 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -1468,9 +1468,9 @@ std::vector target_handler::target_ui( player &pc, target_mode mode, } static const double recoil_per_deg = MAX_RECOIL / 180; - const double phi = fmod( std::abs( coord_to_angle( pc.pos(), dst ) - - coord_to_angle( pc.pos(), recoil_pos ) ), - 360.0 ); + const double phi = std::fmod( std::abs( coord_to_angle( pc.pos(), dst ) - + coord_to_angle( pc.pos(), recoil_pos ) ), + 360.0 ); const double angle = phi > 180.0 ? 360.0 - phi : phi; return std::min( recoil_pc + angle * recoil_per_deg, MAX_RECOIL ); diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index 34d467094207c..d9f46ab5f3aa5 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -3120,11 +3120,11 @@ static void CheckMessages() if( is_default_mode ) { float x1 = ( finger_curr_x - finger_down_x ); float y1 = ( finger_curr_y - finger_down_y ); - float d1 = ( float )( sqrtf( x1 * x1 + y1 * y1 ) ); + float d1 = ( float )( std::sqrtf( x1 * x1 + y1 * y1 ) ); float x2 = ( second_finger_curr_x - second_finger_down_x ); float y2 = ( second_finger_curr_y - second_finger_down_y ); - float d2 = ( float )( sqrtf( x2 * x2 + y2 * y2 ) ); + float d2 = ( float )( std::sqrtf( x2 * x2 + y2 * y2 ) ); float longest_window_edge = std::max( WindowWidth, WindowHeight ); diff --git a/src/simplexnoise.cpp b/src/simplexnoise.cpp index 117676c200451..ac677d860ba30 100644 --- a/src/simplexnoise.cpp +++ b/src/simplexnoise.cpp @@ -187,13 +187,13 @@ float raw_noise_2d( const float x, const float y ) float n2 = 0; // Skew the input space to determine which simplex cell we're in - static const float F2 = 0.5f * ( sqrtf( 3.0f ) - 1.0f ); + static const float F2 = 0.5f * ( std::sqrtf( 3.0f ) - 1.0f ); // Hairy factor for 2D float s = ( x + y ) * F2; int i = fastfloor( x + s ); int j = fastfloor( y + s ); - static const float G2 = ( 3.0f - sqrtf( 3.0f ) ) / 6.0f; + static const float G2 = ( 3.0f - std::sqrtf( 3.0f ) ) / 6.0f; float t = ( i + j ) * G2; // Unskew the cell origin back to (x,y) space float X0 = i - t; @@ -397,8 +397,8 @@ float raw_noise_3d( const float x, const float y, const float z ) float raw_noise_4d( const float x, const float y, const float z, const float w ) { // The skewing and unskewing factors are hairy again for the 4D case - static const float F4 = ( sqrtf( 5.0f ) - 1.0f ) / 4.0f; - static const float G4 = ( 5.0f - sqrtf( 5.0f ) ) / 20.0f; + static const float F4 = ( std::sqrtf( 5.0f ) - 1.0f ) / 4.0f; + static const float G4 = ( 5.0f - std::sqrtf( 5.0f ) ) / 20.0f; float n0, n1, n2, n3, n4; // Noise contributions from the five corners // Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in diff --git a/src/suffer.cpp b/src/suffer.cpp index 1c37b2b760aeb..6bac54b0281d3 100644 --- a/src/suffer.cpp +++ b/src/suffer.cpp @@ -1809,7 +1809,7 @@ void Character::apply_wetness_morale( int temperature ) if( bp_morale < 0 ) { // Damp, hot clothing on hot skin feels bad - scaled_temperature = fabs( scaled_temperature ); + scaled_temperature = std::fabs( scaled_temperature ); } // For an unmutated human swimming in deep water, this will add up to: diff --git a/src/teleport.cpp b/src/teleport.cpp index 86a1a6c61de30..251a79b9a21d0 100644 --- a/src/teleport.cpp +++ b/src/teleport.cpp @@ -44,8 +44,8 @@ bool teleport::teleport( Creature &critter, int min_distance, int max_distance, do { int rangle = rng( 0, 360 ); int rdistance = rng( min_distance, max_distance ); - new_pos.x = origin.x + rdistance * cos( rangle ); - new_pos.y = origin.y + rdistance * sin( rangle ); + new_pos.x = origin.x + rdistance * std::cos( rangle ); + new_pos.y = origin.y + rdistance * std::sin( rangle ); tries++; } while( g->m.impassable( new_pos ) && tries < 20 ); //handles teleporting into solids. diff --git a/src/tileray.cpp b/src/tileray.cpp index c1248bc60132a..3d595eadb7096 100644 --- a/src/tileray.cpp +++ b/src/tileray.cpp @@ -47,7 +47,7 @@ void tileray::init( int adir ) direction = ( adir < 0 ? 360 - ( ( -adir ) % 360 ) : adir % 360 ); last_d = point_zero; float direction_radians = static_cast( direction ) * M_PI / 180.0; - rl_vec2d delta_f( cos( direction_radians ), sin( direction_radians ) ); + rl_vec2d delta_f( std::cos( direction_radians ), std::sin( direction_radians ) ); delta = ( delta_f * 100 ).as_point(); abs_d = abs( delta ); steps = 0; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index bdd6e7c2f474a..eda16b706838d 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1224,7 +1224,7 @@ int vehicle::part_vpower_w( const int index, const bool at_full_hp ) const double raddir = ( ( g->weather.winddirection + 180 ) % 360 ) * ( M_PI / 180 ); windvec = windvec.normalized(); windvec.y = -cos( raddir ); - windvec.x = sin( raddir ); + windvec.x = std::sin( raddir ); rl_vec2d fv = face_vec(); double dot = windvec.dot_product( fv ); if( dot <= 0 ) { @@ -3798,7 +3798,7 @@ void vehicle::noise_and_smoke( int load, time_duration time ) // Cap engine noise to avoid deafening. noise = std::min( noise, 100.0 ); // Even a vehicle with engines off will make noise traveling at high speeds - noise = std::max( noise, static_cast( fabs( velocity / 500.0 ) ) ); + noise = std::max( noise, static_cast( std::fabs( velocity / 500.0 ) ) ); int lvl = 0; if( one_in( 4 ) && rng( 0, 30 ) < noise ) { while( noise > sounds[lvl].second ) { diff --git a/src/vehicle_move.cpp b/src/vehicle_move.cpp index 100a05dae0b32..42872e3558eff 100644 --- a/src/vehicle_move.cpp +++ b/src/vehicle_move.cpp @@ -91,7 +91,7 @@ int vehicle::slowdown( int at_velocity ) const } else if( !is_falling && !is_flying ) { double f_rolling_drag = coeff_rolling_drag() * ( vehicles::rolling_constant_to_variable + mps ); // increase rolling resistance by up to 25x if the vehicle is skidding at right angle to facing - const double skid_factor = 1 + 24 * std::abs( sin( DEGREES( face.dir() - move.dir() ) ) ); + const double skid_factor = 1 + 24 * std::abs( std::sin( DEGREES( face.dir() - move.dir() ) ) ); f_total_drag += f_rolling_drag * skid_factor; } double accel_slowdown = f_total_drag / to_kilogram( total_mass() ); @@ -1215,7 +1215,7 @@ rl_vec2d vehicle::velo_vec() const inline rl_vec2d degree_to_vec( double degrees ) { - return rl_vec2d( cos( degrees * M_PI / 180 ), sin( degrees * M_PI / 180 ) ); + return rl_vec2d( std::cos( degrees * M_PI / 180 ), std::sin( degrees * M_PI / 180 ) ); } // normalized. @@ -1466,7 +1466,7 @@ vehicle *vehicle::act_on_map() const float old_vel = vmiph_to_mps( vertical_velocity ); // Formula is v_2 = sqrt( 2*d*g + v_1^2 ) // Note: That drops the sign - const float new_vel = -sqrt( 2 * tile_height * g + old_vel * old_vel ); + const float new_vel = -std::sqrt( 2 * tile_height * g + old_vel * old_vel ); vertical_velocity = mps_to_vmiph( new_vel ); is_falling = true; } else { diff --git a/src/weather_gen.cpp b/src/weather_gen.cpp index 8233837038e2f..4f14b12c1beba 100644 --- a/src/weather_gen.cpp +++ b/src/weather_gen.cpp @@ -57,7 +57,7 @@ static weather_gen_common get_common_data( const tripoint &location, const time_ const double year_fraction( time_past_new_year( t ) / calendar::year_length() ); // [0,1) - result.cyf = cos( tau * ( year_fraction + .125 ) ); // [-1, 1] + result.cyf = std::cos( tau * ( year_fraction + .125 ) ); // [-1, 1] // We add one-eighth to line up `cyf` so that 1 is at // midwinter and -1 at midsummer. (Cataclsym DDA years // start when spring starts. Gregorian years start when @@ -79,7 +79,7 @@ static double weather_temperature_from_common_data( const weather_generator &wg, // -1 in midwinter, +1 in midsummer const season_type season = common.season; const double dayFraction = time_past_midnight( t ) / 1_days; - const double dayv = cos( tau * ( dayFraction + .5 - coldest_hour / 24 ) ); + const double dayv = std::cos( tau * ( dayFraction + .5 - coldest_hour / 24 ) ); // -1 at coldest_hour, +1 twelve hours later // manually specified seasonal temp variation from region_settings.json @@ -273,10 +273,10 @@ int weather_generator::get_water_temperature() const } // Temperature varies between 33.8F and 75.2F depending on the time of year. Day = 0 corresponds to the start of spring. - int annual_mean_water_temperature = 54.5 + 20.7 * sin( tau * ( day - season_length * 0.5 ) / + int annual_mean_water_temperature = 54.5 + 20.7 * std::sin( tau * ( day - season_length * 0.5 ) / ( season_length * 4.0 ) ); // Temperature varies between +2F and -2F depending on the time of day. Hour = 0 corresponds to midnight. - int daily_water_temperature_varaition = 2.0 + 2.0 * sin( tau * ( hour - 6.0 ) / 24.0 ); + int daily_water_temperature_varaition = 2.0 + 2.0 * std::sin( tau * ( hour - 6.0 ) / 24.0 ); water_temperature = annual_mean_water_temperature + daily_water_temperature_varaition;