I need a function that let me find n random points. These points must have the same distance from a given point. Can you help me?
void createCpoints() { int xcenter=3; int ycenter=3; int radius=3; double x[N]; double y[N]; //... } I need a function that let me find n random points. These points must have the same distance from a given point. Can you help me?
void createCpoints() { int xcenter=3; int ycenter=3; int radius=3; double x[N]; double y[N]; //... } As @5gon12eder says, you could use polar coordinates with the initial point as virtual midpoint:
#include <math.h> //... for(int i = 0; i < n; i++) { double alpha = 2.0d*M_PI*((double) rand() / RAND_MAX); x[i] = radius*cos(alpha)+x0; y[i] = radius*sin(alpha)+y0; } With (x0,y0) the coordinates of the original point.
math.h. And cmath doesn't define constants automatically.