20 std::vector<Point> pointsList;
28 pointsList.push_back(pt);
32 pointsList.push_back(pt);
36 double v[3] = {pt2[0]-pt1[0], pt2[1]-pt1[1], pt2[2]-pt1[2]};
37 double p[3] = {pt1[0],pt1[1],pt1[2]};
41 double nprime = std::ceil(2*dist/
h);
42 double hprime = 1/nprime;
43 double *xx =
new double[(int)nprime+1];
47 for (i = 0; i < nprime; i++){
54 pointsList.reserve((
int) nprime+1);
56 for (i = 0; i<nprime+1; i++){
74 pt.
x = point[0] + v[0]*t;
75 pt.
y = point[1] + v[1]*t;
76 pt.
z = point[2] + v[2]*t;
95 double ck = (std::exp(kappa) - std::exp(-kappa))/kappa;
97 v1[0] = sin(theta)*cos(phi);
98 v1[1] = sin(theta)*sin(phi);
101 double u[3] = {0,0,1};
107 if (!(std::abs(xProd[0]) <=
eps && std::abs(xProd[1]) <=
eps && std::abs(xProd[2]) <=
eps )){
109 double sin = sqrt(xProd[0]*xProd[0] + xProd[1]*xProd[1] + xProd[2]*xProd[2]);
111 double v[9] = {0, -xProd[2], xProd[1], xProd[2], 0, -xProd[0], -xProd[1], xProd[0], 0};
112 double scalar = (1.0f-cos)/(sin*sin);
115 vSquared[0] = (v[0]*v[0] + v[1]*v[3] + v[2]*v[6])*scalar;
116 vSquared[1] = (v[0]*v[1] + v[1]*v[4] + v[2]*v[7])*scalar;
117 vSquared[2] = (v[0]*v[2] + v[1]*v[5] + v[2]*v[8])*scalar;
118 vSquared[3] = (v[3]*v[0] + v[4]*v[3] + v[5]*v[6])*scalar;
119 vSquared[4] = (v[3]*v[1] + v[4]*v[4] + v[5]*v[7])*scalar;
120 vSquared[5] = (v[3]*v[2] + v[4]*v[5] + v[5]*v[8])*scalar;
121 vSquared[6] = (v[6]*v[0] + v[7]*v[3] + v[8]*v[6])*scalar;
122 vSquared[7] = (v[6]*v[1] + v[7]*v[4] + v[8]*v[7])*scalar;
123 vSquared[8] = (v[6]*v[2] + v[7]*v[5] + v[8]*v[8])*scalar;
125 R[0] = 1 + v[0] + vSquared[0];
126 R[1] = 0 + v[1] + vSquared[1];
127 R[2] = 0 + v[2] + vSquared[2];
128 R[3] = 0 + v[3] + vSquared[3];
129 R[4] = 1 + v[4] + vSquared[4];
130 R[5] = 0 + v[5] + vSquared[5];
131 R[6] = 0 + v[6] + vSquared[6];
132 R[7] = 0 + v[7] + vSquared[7];
133 R[8] = 1 + v[8] + vSquared[8];
137 R[0]=1; R[1]=0; R[2]=0;
138 R[3]=0; R[4]=1; R[5]=0;
139 R[6]=0; R[7]=0; R[8]=1;
145 std::uniform_real_distribution<double> thetaDist(0.0,M_PI);
146 std::uniform_real_distribution<double> distribution(0.0,1.0);
147 double thetaRandom = thetaDist(generator);
148 double y = distribution(generator);
149 double V[2] = {std::cos(thetaRandom), std::sin(thetaRandom)};
150 double w = 1/kappa*std::log(std::exp(-kappa)+kappa*ck*y);
151 double temp = std::sqrt(1-(w*w));
157 double *vec =
new double[3];
158 vec[0] =V[0]*R[0] + V[1]*R[1] + w*R[2];
159 vec[1] =V[0]*R[3] + V[1]*R[4] + w*R[5];
160 vec[2] =V[0]*R[6] + V[1]*R[7] + w*R[8];
177 double *
randomTranslation(std::mt19937_64 &generator,
float xMin,
float xMax,
float yMin,
float yMax,
float zMin,
float zMax) {
179 double *t =
new double[3];
182 std::uniform_real_distribution<double> distributionX (xMin, xMax);
183 t[0] = distributionX(generator);
186 std::uniform_real_distribution<double> distributionY (yMin, yMax);
187 t[1] = distributionY(generator);
190 std::uniform_real_distribution<double> distributionZ (zMin, zMax);
191 t[2] = distributionZ(generator);
210 float temp = 1-randomNum + (randomNum*std::pow((min/max), alpha));
211 temp = min * std::pow(temp,(-1/alpha));
229 float b = aspectRatio;
231 double temp1 = ((a-b)/(a+b));
233 double c = M_PI *(a+b)*(1 + (3 * temp1)/(10 + std::sqrt(4-3 * temp1)));
235 double del = c/nPoints;
237 thetaArray =
new float[nPoints];
240 for (
int i = 1; i < nPoints; i++) {
243 tmp = std::pow(b *std::cos(thetaArray[i-1]),2) + (std::pow((a * std::sin(thetaArray[i-1])),2));
245 double f_tmp = del / std::sqrt(tmp);
247 tmp = thetaArray[i-1] + f_tmp;
249 thetaArray[i] = thetaArray[i-1] + 0.5*del*std::pow(std::sqrt(std::pow(b*std::cos(tmp),2) + std::pow(a*std::sin(tmp), 2)),(-1)) + 0.5*f_tmp;
bool greaterThan(float i, float j)
float truncatedPowerLaw(float randomNum, float min, float max, float alpha)
double * randomTranslation(std::mt19937_64 &generator, float xMin, float xMax, float yMin, float yMax, float zMin, float zMax)
T dotProduct(const T *A, const T *B)
double * fisherDistribution(double theta, double phi, double kappa, std::mt19937_64 &generator)
void generateTheta(float *&thetaArray, float aspectRatio, int nPoints)
Point lineFunction3D(double *v, double *point, double t)
T * crossProduct(const T *v1, const T *v2)
std::vector< Point > discretizeLineOfIntersection(double *pt1, double *pt2, double dist)