vectors.h explicit type conversions for C++ compatibility
This commit is contained in:
parent
6820eb3366
commit
89f7400c71
|
@ -359,8 +359,9 @@ static inline csph_t ccart2csph(const ccart3_t cart) {
|
||||||
/// Real 3D cartesian to spherical (complex r) coordinates conversion. See @ref coord_conversions.
|
/// Real 3D cartesian to spherical (complex r) coordinates conversion. See @ref coord_conversions.
|
||||||
static inline csph_t cart2csph(const cart3_t cart) {
|
static inline csph_t cart2csph(const cart3_t cart) {
|
||||||
csph_t sph;
|
csph_t sph;
|
||||||
sph.r = cart3norm(cart);
|
const double r = cart3norm(cart);
|
||||||
sph.theta = sph.r ? acos(cart.z / sph.r) : M_PI_2;
|
sph.r = r;
|
||||||
|
sph.theta = sph.r ? acos(cart.z / r) : M_PI_2;
|
||||||
sph.phi = atan2(cart.y, cart.x);
|
sph.phi = atan2(cart.y, cart.x);
|
||||||
return sph;
|
return sph;
|
||||||
}
|
}
|
||||||
|
@ -579,7 +580,6 @@ static inline double anycoord2cart1(anycoord_point_t p, qpms_coord_system_t t) {
|
||||||
" to 1D not allowed.");
|
" to 1D not allowed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Coordinate conversion of point arrays (something to something).
|
/// Coordinate conversion of point arrays (something to something).
|
||||||
/** The dest and src arrays must not overlap */
|
/** The dest and src arrays must not overlap */
|
||||||
static inline void qpms_array_coord_transform(void *dest, qpms_coord_system_t tdest,
|
static inline void qpms_array_coord_transform(void *dest, qpms_coord_system_t tdest,
|
||||||
|
@ -590,31 +590,31 @@ static inline void qpms_array_coord_transform(void *dest, qpms_coord_system_t td
|
||||||
sph_t *d = (sph_t *) dest;
|
sph_t *d = (sph_t *) dest;
|
||||||
switch (tsrc & QPMS_COORDS_BITRANGE) {
|
switch (tsrc & QPMS_COORDS_BITRANGE) {
|
||||||
case QPMS_COORDS_SPH: {
|
case QPMS_COORDS_SPH: {
|
||||||
const sph_t *s = src;
|
const sph_t *s = (const sph_t*) src;
|
||||||
for(size_t i = 0; i < nmemb; ++i)
|
for(size_t i = 0; i < nmemb; ++i)
|
||||||
d[i] = s[i];
|
d[i] = s[i];
|
||||||
return;
|
return;
|
||||||
} break;
|
} break;
|
||||||
case QPMS_COORDS_CART3: {
|
case QPMS_COORDS_CART3: {
|
||||||
const cart3_t *s = src;
|
const cart3_t *s = (const cart3_t*) src;
|
||||||
for(size_t i = 0; i < nmemb; ++i)
|
for(size_t i = 0; i < nmemb; ++i)
|
||||||
d[i] = cart2sph(s[i]);
|
d[i] = cart2sph(s[i]);
|
||||||
return;
|
return;
|
||||||
} break;
|
} break;
|
||||||
case QPMS_COORDS_POL: {
|
case QPMS_COORDS_POL: {
|
||||||
const pol_t *s = src;
|
const pol_t *s = (const pol_t*) src;
|
||||||
for(size_t i = 0; i < nmemb; ++i)
|
for(size_t i = 0; i < nmemb; ++i)
|
||||||
d[i] = pol2sph_equator(s[i]);
|
d[i] = pol2sph_equator(s[i]);
|
||||||
return;
|
return;
|
||||||
} break;
|
} break;
|
||||||
case QPMS_COORDS_CART2: {
|
case QPMS_COORDS_CART2: {
|
||||||
const cart2_t *s = src;
|
const cart2_t *s = (const cart2_t*) src;
|
||||||
for(size_t i = 0; i < nmemb; ++i)
|
for(size_t i = 0; i < nmemb; ++i)
|
||||||
d[i] = cart22sph(s[i]);
|
d[i] = cart22sph(s[i]);
|
||||||
return;
|
return;
|
||||||
} break;
|
} break;
|
||||||
case QPMS_COORDS_CART1: {
|
case QPMS_COORDS_CART1: {
|
||||||
const double *s = src;
|
const double *s = (const double *) src;
|
||||||
for(size_t i = 0; i < nmemb; ++i)
|
for(size_t i = 0; i < nmemb; ++i)
|
||||||
d[i] = cart12sph_zaxis(s[i]);
|
d[i] = cart12sph_zaxis(s[i]);
|
||||||
return;
|
return;
|
||||||
|
@ -628,31 +628,31 @@ static inline void qpms_array_coord_transform(void *dest, qpms_coord_system_t td
|
||||||
cart3_t *d = (cart3_t *) dest;
|
cart3_t *d = (cart3_t *) dest;
|
||||||
switch (tsrc & QPMS_COORDS_BITRANGE) {
|
switch (tsrc & QPMS_COORDS_BITRANGE) {
|
||||||
case QPMS_COORDS_SPH: {
|
case QPMS_COORDS_SPH: {
|
||||||
const sph_t *s = src;
|
const sph_t *s = (const sph_t *) src;
|
||||||
for(size_t i = 0; i < nmemb; ++i)
|
for(size_t i = 0; i < nmemb; ++i)
|
||||||
d[i] = sph2cart(s[i]);
|
d[i] = sph2cart(s[i]);
|
||||||
return;
|
return;
|
||||||
} break;
|
} break;
|
||||||
case QPMS_COORDS_CART3: {
|
case QPMS_COORDS_CART3: {
|
||||||
const cart3_t *s = src;
|
const cart3_t *s = (const cart3_t *) src;
|
||||||
for(size_t i = 0; i < nmemb; ++i)
|
for(size_t i = 0; i < nmemb; ++i)
|
||||||
d[i] = s[i];
|
d[i] = s[i];
|
||||||
return;
|
return;
|
||||||
} break;
|
} break;
|
||||||
case QPMS_COORDS_POL: {
|
case QPMS_COORDS_POL: {
|
||||||
const pol_t *s = src;
|
const pol_t *s = (const pol_t *) src;
|
||||||
for(size_t i = 0; i < nmemb; ++i)
|
for(size_t i = 0; i < nmemb; ++i)
|
||||||
d[i] = pol2cart3_equator(s[i]);
|
d[i] = pol2cart3_equator(s[i]);
|
||||||
return;
|
return;
|
||||||
} break;
|
} break;
|
||||||
case QPMS_COORDS_CART2: {
|
case QPMS_COORDS_CART2: {
|
||||||
const cart2_t *s = src;
|
const cart2_t *s = (const cart2_t *) src;
|
||||||
for(size_t i = 0; i < nmemb; ++i)
|
for(size_t i = 0; i < nmemb; ++i)
|
||||||
d[i] = cart22cart3xy(s[i]);
|
d[i] = cart22cart3xy(s[i]);
|
||||||
return;
|
return;
|
||||||
} break;
|
} break;
|
||||||
case QPMS_COORDS_CART1: {
|
case QPMS_COORDS_CART1: {
|
||||||
const double *s = src;
|
const double *s = (const double *)src;
|
||||||
for(size_t i = 0; i < nmemb; ++i)
|
for(size_t i = 0; i < nmemb; ++i)
|
||||||
d[i] = cart12cart3z(s[i]);
|
d[i] = cart12cart3z(s[i]);
|
||||||
return;
|
return;
|
||||||
|
@ -670,13 +670,13 @@ static inline void qpms_array_coord_transform(void *dest, qpms_coord_system_t td
|
||||||
QPMS_PR_ERROR("Implicit conversion from 3D to 2D coordinates not allowed");
|
QPMS_PR_ERROR("Implicit conversion from 3D to 2D coordinates not allowed");
|
||||||
break;
|
break;
|
||||||
case QPMS_COORDS_POL: {
|
case QPMS_COORDS_POL: {
|
||||||
const pol_t *s = src;
|
const pol_t *s = (const pol_t *) src;
|
||||||
for(size_t i = 0; i < nmemb; ++i)
|
for(size_t i = 0; i < nmemb; ++i)
|
||||||
d[i] = s[i];
|
d[i] = s[i];
|
||||||
return;
|
return;
|
||||||
} break;
|
} break;
|
||||||
case QPMS_COORDS_CART2: {
|
case QPMS_COORDS_CART2: {
|
||||||
const cart2_t *s = src;
|
const cart2_t *s = (const cart2_t *) src;
|
||||||
for(size_t i = 0; i < nmemb; ++i)
|
for(size_t i = 0; i < nmemb; ++i)
|
||||||
d[i] = cart2pol(s[i]);
|
d[i] = cart2pol(s[i]);
|
||||||
return;
|
return;
|
||||||
|
@ -697,13 +697,13 @@ static inline void qpms_array_coord_transform(void *dest, qpms_coord_system_t td
|
||||||
QPMS_PR_ERROR("Implicit conversion from 3D to 2D coordinates not allowed");
|
QPMS_PR_ERROR("Implicit conversion from 3D to 2D coordinates not allowed");
|
||||||
break;
|
break;
|
||||||
case QPMS_COORDS_POL: {
|
case QPMS_COORDS_POL: {
|
||||||
const pol_t *s = src;
|
const pol_t *s = (const pol_t *) src;
|
||||||
for(size_t i = 0; i < nmemb; ++i)
|
for(size_t i = 0; i < nmemb; ++i)
|
||||||
d[i] = pol2cart(s[i]);
|
d[i] = pol2cart(s[i]);
|
||||||
return;
|
return;
|
||||||
} break;
|
} break;
|
||||||
case QPMS_COORDS_CART2: {
|
case QPMS_COORDS_CART2: {
|
||||||
const cart2_t *s = src;
|
const cart2_t *s = (const cart2_t *) src;
|
||||||
for(size_t i = 0; i < nmemb; ++i)
|
for(size_t i = 0; i < nmemb; ++i)
|
||||||
d[i] = s[i];
|
d[i] = s[i];
|
||||||
return;
|
return;
|
||||||
|
@ -728,7 +728,7 @@ static inline void qpms_array_coord_transform(void *dest, qpms_coord_system_t td
|
||||||
QPMS_PR_ERROR("Implicit conversion from 3D to 1D coordinates not allowed");
|
QPMS_PR_ERROR("Implicit conversion from 3D to 1D coordinates not allowed");
|
||||||
break;
|
break;
|
||||||
case QPMS_COORDS_CART1: {
|
case QPMS_COORDS_CART1: {
|
||||||
const double *s = src;
|
const double *s = (const double *) src;
|
||||||
for(size_t i = 0; i < nmemb; ++i)
|
for(size_t i = 0; i < nmemb; ++i)
|
||||||
d[i] = s[i];
|
d[i] = s[i];
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue