#include "random_dir.h" #include #include Eigen::Vector3d igl::random_dir() { using namespace Eigen; using namespace igl; double z = (double)rand() / (double)RAND_MAX*2.0 - 1.0; double t = (double)rand() / (double)RAND_MAX*2.0*PI; // http://www.altdevblogaday.com/2012/05/03/generating-uniformly-distributed-points-on-sphere/ double r = sqrt(1.0-z*z); double x = r * cos(t); double y = r * sin(t); return Vector3d(x,y,z); } Eigen::MatrixXd igl::random_dir_stratified(const int n) { using namespace Eigen; using namespace igl; using namespace std; const double m = floor(sqrt(double(n))); MatrixXd N(n,3); int row = 0; for(int i = 0;i