fix z-axis latticegen
Former-commit-id: ab81c5470a3e8831f3ca38dbed54cf7c5d04ce90
This commit is contained in:
parent
6b88106cce
commit
45eadd13db
|
@ -175,7 +175,7 @@ PGenSph PGenSph_zAxis_new_minMaxR(double period, double offset, double minR, boo
|
||||||
s->ptindex = ptindex_inc(s->ptindex);
|
s->ptindex = ptindex_inc(s->ptindex);
|
||||||
break;
|
break;
|
||||||
case PGENSPH_ZAXIS_INC_TOWARDS_ORIGIN:
|
case PGENSPH_ZAXIS_INC_TOWARDS_ORIGIN:
|
||||||
s->ptindex = - ceil(minR / fabs(period));
|
s->ptindex = - ceil(maxR / fabs(period));
|
||||||
while ( (curR = fabs(s->offset + s->ptindex * period)) > maxR || (!inc_minR && curR >= maxR))
|
while ( (curR = fabs(s->offset + s->ptindex * period)) > maxR || (!inc_minR && curR >= maxR))
|
||||||
s->ptindex = ptindex_dec(s->ptindex);
|
s->ptindex = ptindex_dec(s->ptindex);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -57,7 +57,11 @@ static inline sph_t cart2sph(const cart3_t cart) {
|
||||||
|
|
||||||
static inline cart3_t sph2cart(const sph_t sph) {
|
static inline cart3_t sph2cart(const sph_t sph) {
|
||||||
cart3_t cart;
|
cart3_t cart;
|
||||||
double sin_th = sin(sph.theta);
|
double sin_th =
|
||||||
|
#ifdef QPMS_VECTORS_NICE_TRANSFORMATIONS
|
||||||
|
(sph.theta == M_PI) ? 0 :
|
||||||
|
#endif
|
||||||
|
sin(sph.theta);
|
||||||
cart.x = sph.r * sin_th * cos(sph.phi);
|
cart.x = sph.r * sin_th * cos(sph.phi);
|
||||||
cart.y = sph.r * sin_th * sin(sph.phi);
|
cart.y = sph.r * sin_th * sin(sph.phi);
|
||||||
cart.z = sph.r * cos(sph.theta);
|
cart.z = sph.r * cos(sph.theta);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//c99 -o test_latticegens -ggdb -Wall -I ../ test_latticegens.c ../qpms/latticegens.c -lm
|
//c99 -o test_latticegens -ggdb -Wall -I ../ test_latticegens.c ../qpms/latticegens.c -lm
|
||||||
|
#define QPMS_VECTORS_NICE_TRANSFORMATIONS
|
||||||
#include <qpms/lattices.h>
|
#include <qpms/lattices.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -34,5 +34,15 @@ int main(int argc, char **argv) {
|
||||||
dump_PGenSph(&g);
|
dump_PGenSph(&g);
|
||||||
DO_AND_PRINT(test3b, g = PGenSph_zAxis_new_minMaxR(0.2, 0.05, 5.05, false, 7.05, false, PGENSPH_ZAXIS_INC_TOWARDS_ORIGIN))
|
DO_AND_PRINT(test3b, g = PGenSph_zAxis_new_minMaxR(0.2, 0.05, 5.05, false, 7.05, false, PGENSPH_ZAXIS_INC_TOWARDS_ORIGIN))
|
||||||
dump_PGenSph(&g);
|
dump_PGenSph(&g);
|
||||||
|
DO_AND_PRINT(test4a, g = PGenSph_zAxis_new_minMaxR(0.2, 0.0, 0, false, 1, false, PGENSPH_ZAXIS_INC_FROM_ORIGIN))
|
||||||
|
dump_PGenSph(&g);
|
||||||
|
DO_AND_PRINT(test4b, g = PGenSph_zAxis_new_minMaxR(0.2, 0.0, 0, false, 1, false, PGENSPH_ZAXIS_INC_TOWARDS_ORIGIN))
|
||||||
|
dump_PGenSph(&g);
|
||||||
|
DO_AND_PRINT(test5a, g = PGenSph_zAxis_new_minMaxR(0.2, 0.0, 0, true, 1, true, PGENSPH_ZAXIS_INC_FROM_ORIGIN))
|
||||||
|
dump_PGenSph(&g);
|
||||||
|
DO_AND_PRINT(test5b, g = PGenSph_zAxis_new_minMaxR(0.2, 0.0, 0, true, 1, true, PGENSPH_ZAXIS_INC_TOWARDS_ORIGIN))
|
||||||
|
dump_PGenSph(&g);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue