From 2ec5702f540e3c22ed847faed45f519a9bfad385 Mon Sep 17 00:00:00 2001 From: Joaquim Date: Tue, 21 Jan 2025 02:18:17 +0000 Subject: [PATCH 1/3] Fix a bug in assigning the center coordinates of sphere bodies. --- src/potential/gmtgravmag3d.c | 4 ++-- src/potential/solids.c | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/potential/gmtgravmag3d.c b/src/potential/gmtgravmag3d.c index fabd64a7e9a..32774a3c203 100644 --- a/src/potential/gmtgravmag3d.c +++ b/src/potential/gmtgravmag3d.c @@ -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; @@ -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; diff --git a/src/potential/solids.c b/src/potential/solids.c index fb9537ae5ba..4a2f43b6fbb 100644 --- a/src/potential/solids.c +++ b/src/potential/solids.c @@ -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)); From 6eff2b727d420ea2c5ae1e84fbe88a970b585886 Mon Sep 17 00:00:00 2001 From: Joaquim Date: Tue, 21 Jan 2025 02:39:53 +0000 Subject: [PATCH 2/3] Change error message --- src/potential/gmtgravmag3d.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/potential/gmtgravmag3d.c b/src/potential/gmtgravmag3d.c index 32774a3c203..5246622bb8f 100644 --- a/src/potential/gmtgravmag3d.c +++ b/src/potential/gmtgravmag3d.c @@ -363,7 +363,7 @@ static int parse(struct GMT_CTRL *GMT, struct GMTGRAVMAG3D_CTRL *Ctrl, struct GM 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)."); + 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; @@ -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; From d9c95fc33a47ace6f04f5d5ee085fce892d7e9d7 Mon Sep 17 00:00:00 2001 From: Joaquim Date: Tue, 21 Jan 2025 02:46:07 +0000 Subject: [PATCH 3/3] Fix an issue with 'ellipsoid' too. --- src/potential/gmtgravmag3d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/potential/gmtgravmag3d.c b/src/potential/gmtgravmag3d.c index 5246622bb8f..36124ab9e6b 100644 --- a/src/potential/gmtgravmag3d.c +++ b/src/potential/gmtgravmag3d.c @@ -362,7 +362,7 @@ 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) { + 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; }