Ignore:
Timestamp:
09/21/15 19:13:26 (10 years ago)
Author:
epyon
Message:
  • full math library
  • GLM dependency removed
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/random.cc

    r454 r471  
    2121void random::mt_init( uint32 seed )
    2222{
    23         m_state[0] = static_cast<uint32_t>( seed & mt_full_mask );
     23        m_state[0] = static_cast<uint32>( seed & mt_full_mask );
    2424        for ( int i = 1; i < mersenne_n; i++ )
    2525        {
     
    111111{
    112112        f32 angle = frand( math::pi<f32>() * 2.f );
    113         return vec2( math::cos( angle ), math::sin( angle ) );
     113        return vec2( cos( angle ), sin( angle ) );
    114114}
    115115
     
    117117{
    118118        f32 cos_theta = frange( -1.0f, 1.0f );
    119         f32 sin_theta = math::sqrt( 1.0f - cos_theta * cos_theta );
     119        f32 sin_theta = sqrt( 1.0f - cos_theta * cos_theta );
    120120        f32 phi       = frand( 2 * math::pi<f32>() );
    121121        return vec3(
    122                 sin_theta * math::sin(phi),
    123                 sin_theta * math::cos(phi),
     122                sin_theta * sin(phi),
     123                sin_theta * cos(phi),
    124124                cos_theta
    125125                );
     
    132132        if ( r1 > r2 ) swap( r1, r2 );
    133133        f32 rf = 2* math::pi<f32>()*(r1/r2);
    134         return vec2( r2*math::cos( rf ), r2*math::sin( rf ) );
     134        return vec2( r2*cos( rf ), r2*sin( rf ) );
    135135}
    136136
    137137nv::vec2 nv::random::precise_disk_point()
    138138{
    139         f32 r = math::sqrt( frand() );
     139        f32 r = sqrt( frand() );
    140140        f32 rangle = frand( math::pi<f32>() );
    141         return vec2( r*math::cos( rangle ), r*math::sin( rangle ) );
     141        return vec2( r*cos( rangle ), r*sin( rangle ) );
    142142}
    143143
     
    146146        f32 rad     = frand();
    147147        f32 pi      = math::pi<f32>();
    148         f32 phi     = math::asin( frange( -1.0f, 1.0f ) ) + pi*.5f;
     148        f32 phi     = asin( frange( -1.0f, 1.0f ) ) + pi*.5f;
    149149        f32 theta   = frange( 0.0f, 2 * math::pi<f32>() );
    150         f32 sin_phi = math::sin( phi );
     150        f32 sin_phi = sin( phi );
    151151        return vec3(
    152                 rad * math::cos(theta) * sin_phi,
    153                 rad * math::sin(theta) * sin_phi,
    154                 rad * math::cos(phi)
     152                rad * cos(theta) * sin_phi,
     153                rad * sin(theta) * sin_phi,
     154                rad * cos(phi)
    155155        );
    156156}
     
    158158nv::vec3 nv::random::precise_sphere_point()
    159159{
    160         f32 radius = math::pow( frand(), 1.f/3.f );
     160        f32 radius = pow( frand(), 1.f/3.f );
    161161        f32 cos_theta = frange( -1.0f, 1.0f );
    162         f32 sin_theta = math::sqrt( 1.0f - cos_theta * cos_theta );
     162        f32 sin_theta = sqrt( 1.0f - cos_theta * cos_theta );
    163163        f32 phi       = frange( 0.0f, 2 * math::pi<f32>() );
    164164        return vec3(
    165                 radius * sin_theta * math::sin(phi),
    166                 radius * sin_theta * math::cos(phi),
     165                radius * sin_theta * sin(phi),
     166                radius * sin_theta * cos(phi),
    167167                radius * cos_theta
    168168                );
     
    203203        f32 idist2 = iradius * iradius;
    204204        f32 odist2 = oradius * oradius;
    205         f32 rdist  = math::sqrt( frange( idist2, odist2 ) );
     205        f32 rdist  = sqrt( frange( idist2, odist2 ) );
    206206        return rdist * precise_unit_vec2();
    207207}
     
    216216        f32 idist3 = iradius * iradius * iradius;
    217217        f32 odist3 = oradius * oradius * oradius;
    218         f32 rdist  = math::pow( frange( idist3, odist3 ), 1.f/3.f );
     218        f32 rdist  = pow( frange( idist3, odist3 ), 1.f/3.f );
    219219        return rdist * precise_unit_vec3();
    220220}
     
    237237        f32 idist2 = ((iradii2.x * iradii2.y) / low ) * odist2;
    238238
    239         f32 rdist     = math::sqrt( frange( idist2, odist2 ) );
     239        f32 rdist     = sqrt( frange( idist2, odist2 ) );
    240240        return odir * rdist;   
    241241}
     
    260260        f32 idist2 = ((iradii2.x * iradii2.y * iradii2.z) / low ) * odist2;
    261261
    262         f32 odist3 = odist2 * math::sqrt( odist2 );
    263         f32 idist3 = idist2 * math::sqrt( idist2 );
    264 
    265         f32 rdist     = math::pow( frange( idist3, odist3 ), 1.f/3.f );
     262        f32 odist3 = odist2 * sqrt( odist2 );
     263        f32 idist3 = idist2 * sqrt( idist2 );
     264
     265        f32 rdist     = pow( frange( idist3, odist3 ), 1.f/3.f );
    266266        return odir * rdist;   
    267267}
Note: See TracChangeset for help on using the changeset viewer.