| 307 | //----------------------------------------------------------------------------- |
| 308 | |
| 309 | Point2F randomPointInCircle( F32 radius ) |
| 310 | { |
| 311 | AssertFatal( radius > 0.0f, "MathUtils::randomPointInRadius - radius must be positive" ); |
| 312 | |
| 313 | #define MAX_TRIES 20 |
| 314 | |
| 315 | Point2F out; |
| 316 | F32 radiusSq = radius * radius; |
| 317 | |
| 318 | for ( S32 i = 0; i < MAX_TRIES; i++ ) |
| 319 | { |
| 320 | out.x = sgRandom.randF(-radius,radius); |
| 321 | out.y = sgRandom.randF(-radius,radius); |
| 322 | |
| 323 | if ( out.lenSquared() < radiusSq ) |
| 324 | return out; |
| 325 | } |
| 326 | |
| 327 | AssertFatal( false, "MathUtils::randomPointInRadius - something is wrong, should not fail this many times." ); |
| 328 | return Point2F::Zero; |
| 329 | } |
| 330 | |
| 331 | //----------------------------------------------------------------------------- |
| 332 |
no test coverage detected