Program Listing for File random.h

Return to documentation for file (include/fields2cover/utils/random.h)

//=============================================================================
//    Copyright (C) 2021-2024 Wageningen University - All Rights Reserved
//                     Author: Gonzalo Mier
//                        BSD-3 License
//=============================================================================

#pragma once
#ifndef FIELDS2COVER_UTILS_RANDOM_H_
#define FIELDS2COVER_UTILS_RANDOM_H_

#include <time.h>
#include <limits>
#include <random>
#include <boost/math/constants/constants.hpp>
#include "fields2cover/types/Point.h"
#include "fields2cover/types/LineString.h"
#include "fields2cover/types/LinearRing.h"
#include "fields2cover/types/Field.h"
#include "fields2cover/types/Cell.h"

namespace f2c {

class Random {
 public:
  explicit Random(uint32_t seed = static_cast<uint32_t>(time(NULL)));

  ~Random();
  Random(const Random&);
  Random &operator=(const Random&);
  Random(Random&&);
  Random &operator=(Random&&);

 public:
  double getRandomDouble();

  double getRandomLinear(double min, double max);

  double getRandomExp(double min, double max);

  double getRandomExpDist(double lambda);

  double getAngleRandom();

  f2c::types::Cell generateRandCell(double area, int n_sides,
      double min_width = 0.5, double max_width = 1.0);
  f2c::types::Field generateRandField(double area, int n_sides,
      double min_width = 0.5, double max_width = 1.0);

  f2c::types::Cell genConvexCell(double area, size_t n_sides = 4);
  f2c::types::Field genConvexField(double area, size_t n_sides = 4);

  f2c::types::Cell genNonConvexCell(double area);
  f2c::types::Field genNonConvexField(double area);

 private:
  std::mt19937 mt_;
};


}  // namespace f2c

#endif  // FIELDS2COVER_UTILS_RANDOM_H_