hey so I want this function to return an array with 1 row and 3 columns, don't worry about format it is needed. I'm getting too many initializes error. Also other comments would be greatly appreciated. This program is trying to find displacement between 2 particles. Here's the function implemented in my code.
double displacement(double x1, double x2, double y1, double y2, double z1, double z2){
double ddx, ddy, ddz, ddxf, ddyf, ddzf;
double disp[1][3] = { { 0.0 }, { 0.0 }, { 0.0 } };
ddx = x1 - x2; ddy = y1 - y2; ddz = z1 - z2;
if (ddx > L / 2){
ddxf = ddx - L;
}
else if (ddx < -L / 2){
ddxf = ddx + L;
}
else { ddxf = ddx; }
if (ddy > L / 2){
ddyf = ddy - L;
}
else if (ddy < -L / 2){
ddyf = ddy + L;
}
else { ddyf = ddy; }
if (ddz > L / 2){
ddzf = ddz - L;
}
else if (ddz < -L / 2){
ddzf = ddz + L;
}
else { ddzf = ddz; }
return disp[1][3] = { ddxf }, { ddyf }, { ddzf } };
}
Aucun commentaire:
Enregistrer un commentaire