Changeset 471 for trunk/src/core/random.cc
- Timestamp:
- 09/21/15 19:13:26 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/random.cc
r454 r471 21 21 void random::mt_init( uint32 seed ) 22 22 { 23 m_state[0] = static_cast<uint32 _t>( seed & mt_full_mask );23 m_state[0] = static_cast<uint32>( seed & mt_full_mask ); 24 24 for ( int i = 1; i < mersenne_n; i++ ) 25 25 { … … 111 111 { 112 112 f32 angle = frand( math::pi<f32>() * 2.f ); 113 return vec2( math::cos( angle ), math::sin( angle ) );113 return vec2( cos( angle ), sin( angle ) ); 114 114 } 115 115 … … 117 117 { 118 118 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 ); 120 120 f32 phi = frand( 2 * math::pi<f32>() ); 121 121 return vec3( 122 sin_theta * math::sin(phi),123 sin_theta * math::cos(phi),122 sin_theta * sin(phi), 123 sin_theta * cos(phi), 124 124 cos_theta 125 125 ); … … 132 132 if ( r1 > r2 ) swap( r1, r2 ); 133 133 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 ) ); 135 135 } 136 136 137 137 nv::vec2 nv::random::precise_disk_point() 138 138 { 139 f32 r = math::sqrt( frand() );139 f32 r = sqrt( frand() ); 140 140 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 ) ); 142 142 } 143 143 … … 146 146 f32 rad = frand(); 147 147 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; 149 149 f32 theta = frange( 0.0f, 2 * math::pi<f32>() ); 150 f32 sin_phi = math::sin( phi );150 f32 sin_phi = sin( phi ); 151 151 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) 155 155 ); 156 156 } … … 158 158 nv::vec3 nv::random::precise_sphere_point() 159 159 { 160 f32 radius = math::pow( frand(), 1.f/3.f );160 f32 radius = pow( frand(), 1.f/3.f ); 161 161 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 ); 163 163 f32 phi = frange( 0.0f, 2 * math::pi<f32>() ); 164 164 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), 167 167 radius * cos_theta 168 168 ); … … 203 203 f32 idist2 = iradius * iradius; 204 204 f32 odist2 = oradius * oradius; 205 f32 rdist = math::sqrt( frange( idist2, odist2 ) );205 f32 rdist = sqrt( frange( idist2, odist2 ) ); 206 206 return rdist * precise_unit_vec2(); 207 207 } … … 216 216 f32 idist3 = iradius * iradius * iradius; 217 217 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 ); 219 219 return rdist * precise_unit_vec3(); 220 220 } … … 237 237 f32 idist2 = ((iradii2.x * iradii2.y) / low ) * odist2; 238 238 239 f32 rdist = math::sqrt( frange( idist2, odist2 ) );239 f32 rdist = sqrt( frange( idist2, odist2 ) ); 240 240 return odir * rdist; 241 241 } … … 260 260 f32 idist2 = ((iradii2.x * iradii2.y * iradii2.z) / low ) * odist2; 261 261 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 ); 266 266 return odir * rdist; 267 267 }
Note: See TracChangeset
for help on using the changeset viewer.