Skip to content

Commit

Permalink
Fix a bug in assigning the center coordinates of sphere bodies.
Browse files Browse the repository at this point in the history
  • Loading branch information
joa-quim committed Jan 21, 2025
1 parent 7a3806e commit 2ec5702
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 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 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

0 comments on commit 2ec5702

Please sign in to comment.