Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug in assigning the center coordinates of sphere bodies. #8679

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/potential/gmtgravmag3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ static int parse(struct GMT_CTRL *GMT, struct GMTGRAVMAG3D_CTRL *Ctrl, struct GM
if (n_par < 8) Ctrl->M.params[BELL][nBELL][7] = Ctrl->npts_circ;
if (n_par < 9) Ctrl->M.params[BELL][nBELL][8] = Ctrl->n_slices;
if (Ctrl->M.params[BELL][nBELL][6] || Ctrl->M.params[SPHERE][nSPHERE][7] <= 0 || Ctrl->M.params[SPHERE][nSPHERE][8] <= 0) {
GMT_Report (API, GMT_MSG_ERROR, "Bad parameters for the 'bell' body. Please, RTFM (read the manual).");
GMT_Report(API, GMT_MSG_ERROR, "Bad parameters for the 'bell' body. Please, read the manual.");
return GMT_PARSE_ERROR;
}
Ctrl->M.type[BELL][nBELL] = BELL;
Expand All @@ -344,7 +344,7 @@ static int parse(struct GMT_CTRL *GMT, struct GMTGRAVMAG3D_CTRL *Ctrl, struct GM
if (n_par < 3) err_npar = 1;
if (n_par < 6) Ctrl->M.params[CYLINDER][nCIL][5] = Ctrl->npts_circ;
if (Ctrl->M.params[SPHERE][nSPHERE][5] <= 0) {
GMT_Report (API, GMT_MSG_ERROR, "Bad parameters for the 'cylinder' body. Please, RTFM (read the manual).");
GMT_Report(API, GMT_MSG_ERROR, "Bad parameters for the 'cylinder' body. Please, read the manual.");
return GMT_PARSE_ERROR;
}
Ctrl->M.type[CYLINDER][nCIL] = CYLINDER;
Expand All @@ -362,8 +362,8 @@ static int parse(struct GMT_CTRL *GMT, struct GMTGRAVMAG3D_CTRL *Ctrl, struct GM
if (n_par < 4) err_npar = 1;
if (n_par < 7) Ctrl->M.params[ELLIPSOID][nELL][6] = Ctrl->npts_circ;
if (n_par < 8) Ctrl->M.params[ELLIPSOID][nELL][7] = Ctrl->n_slices;
if (Ctrl->M.params[SPHERE][nSPHERE][6] <= 0 || Ctrl->M.params[SPHERE][nSPHERE][7] <= 0) {
GMT_Report (API, GMT_MSG_ERROR, "Bad parameters for the 'ellipsoid' body. Please, RTFM (read the manual).");
if (Ctrl->M.params[ELLIPSOID][nELL][6] <= 0 || Ctrl->M.params[ELLIPSOID][nELL][7] <= 0) {
GMT_Report (API, GMT_MSG_ERROR, "Bad parameters for the 'ellipsoid' body. Please, read the manual.");
return GMT_PARSE_ERROR;
}
Ctrl->M.type[ELLIPSOID][nELL] = ELLIPSOID;
Expand All @@ -387,7 +387,7 @@ static int parse(struct GMT_CTRL *GMT, struct GMTGRAVMAG3D_CTRL *Ctrl, struct GM
if (n_par < 5) Ctrl->M.params[SPHERE][nSPHERE][4] = Ctrl->npts_circ;
if (n_par < 6) Ctrl->M.params[SPHERE][nSPHERE][5] = Ctrl->n_slices;
if (Ctrl->M.params[SPHERE][nSPHERE][4] <= 0 || Ctrl->M.params[SPHERE][nSPHERE][5] <= 0) {
GMT_Report (API, GMT_MSG_ERROR, "Bad parameters for the 'sphere' body. Please, RTFM (read the manual).");
GMT_Report (API, GMT_MSG_ERROR, "Bad parameters for the 'sphere' body. Please, read the manual.");
return GMT_PARSE_ERROR;
}
Ctrl->M.type[SPHERE][nSPHERE] = SPHERE;
Expand Down
8 changes: 8 additions & 0 deletions src/potential/solids.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ int five_psoid(struct GMT_CTRL *GMT, struct GMTGRAVMAG3D_CTRL *Ctrl, int body_ty
a = Ctrl->M.params[body_type][nb][0]; b = Ctrl->M.params[body_type][nb][1];
c = Ctrl->M.params[body_type][nb][2]; z_c = Ctrl->M.params[body_type][nb][3];
x0 = Ctrl->M.params[body_type][nb][4]; y0 = Ctrl->M.params[body_type][nb][5];
if (body_type == SPHERE) { /* This has less parameters so the above is wrong. */
b = c = a; z_c = Ctrl->M.params[body_type][nb][1];
x0 = Ctrl->M.params[body_type][nb][2]; y0 = Ctrl->M.params[body_type][nb][3];
}
if (body_type == BELL) {
a = b; b = c; c = Ctrl->M.params[body_type][nb][0];
}

z_top = z_c + c; z_bot = z_c;

n_tri = (hemi) ? 2 * npts_circ * n_slices : 2 * (npts_circ * (n_slices*2 - 1));
Expand Down
Loading