Blame c++/vector/random.h
|
|
145120 |
|
|
|
145120 |
|
|
|
145120 |
#include <cstdlib></cstdlib>
|
|
|
145120 |
|
|
|
145120 |
#include "real.h"
|
|
|
145120 |
#include "vector.h"
|
|
|
145120 |
|
|
|
145120 |
|
|
|
145120 |
namespace rnd {
|
|
|
145120 |
Real real()
|
|
|
145120 |
{ return Real(rand())/Real(RAND_MAX); }
|
|
|
145120 |
Real real(const Real &max)
|
|
|
145120 |
{ return real()*max; }
|
|
|
145120 |
Real real(const Real &min, const Real &max)
|
|
|
145120 |
{ return min + real(max - min); }
|
|
|
145120 |
|
|
|
145120 |
Vector vector()
|
|
|
145120 |
{ return Vector(real(), real()); }
|
|
|
145120 |
Vector vector(const Real &maxx, const Real &maxy)
|
|
|
145120 |
{ return Vector(real(maxx), real(maxy)); }
|
|
|
145120 |
Vector vector(const Real &minx, const Real &miny, const Real &maxx, const Real &maxy)
|
|
|
145120 |
{ return Vector(real(minx, maxx), real(miny, maxy)); }
|
|
|
145120 |
Vector vector(const Vector &max)
|
|
|
145120 |
{ return vector(max.x, max.y); }
|
|
|
145120 |
Vector vector(const Vector &min, const Vector &max)
|
|
|
145120 |
{ return vector(min.x, min.y, max.x, max.y); }
|
|
|
145120 |
}
|