2018-08-23 11:38:58 +03:00
|
|
|
#include <qpms/lattices.h>
|
|
|
|
#include <stdio.h>
|
2018-08-26 22:36:45 +03:00
|
|
|
#include <float.h>
|
2018-08-23 11:38:58 +03:00
|
|
|
|
|
|
|
void dump_points2d_rordered(const points2d_rordered_t *ps, char *filename) {
|
|
|
|
FILE *f = fopen(filename, "w");
|
|
|
|
for (size_t i = 0; i < ps->nrs; ++i) {
|
|
|
|
fprintf(f, "# r = %.16g\n", ps->rs[i]);
|
|
|
|
for (ptrdiff_t j = ps->r_offsets[i]; j < ps->r_offsets[i+1]; ++j)
|
|
|
|
fprintf(f, "%.16g %.16g\n", ps->base[j].x, ps->base[j].y);
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
2018-08-25 01:16:50 +03:00
|
|
|
triangular_lattice_gen_t *g = triangular_lattice_gen_init(5, TRIANGULAR_HORIZONTAL, false,0);
|
2018-08-23 11:38:58 +03:00
|
|
|
dump_points2d_rordered(&(g->ps), "triang_h_empty.out");
|
|
|
|
|
|
|
|
points2d_rordered_t *p = points2d_rordered_scale(&(g->ps), 1.5464);
|
|
|
|
dump_points2d_rordered(p, "triang_h_empty_scaled.out");
|
|
|
|
|
|
|
|
points2d_rordered_free(p);
|
|
|
|
triangular_lattice_gen_free(g);
|
|
|
|
|
2018-08-25 01:16:50 +03:00
|
|
|
g = triangular_lattice_gen_init(5, TRIANGULAR_HORIZONTAL, false,0);
|
2018-08-23 11:38:58 +03:00
|
|
|
triangular_lattice_gen_extend_to_steps(g, 5);
|
|
|
|
dump_points2d_rordered(&(g->ps), "triang_h_s5.out");
|
|
|
|
triangular_lattice_gen_extend_to_steps(g, 20);
|
|
|
|
dump_points2d_rordered(&(g->ps), "triang_h_s20.out");
|
|
|
|
triangular_lattice_gen_extend_to_steps(g, 160);
|
|
|
|
dump_points2d_rordered(&(g->ps), "triang_h_s160.out");
|
|
|
|
triangular_lattice_gen_extend_to_steps(g, 20);
|
|
|
|
dump_points2d_rordered(&(g->ps), "triang_h_s160_20.out");
|
|
|
|
p = points2d_rordered_scale(&(g->ps), -.2);
|
|
|
|
dump_points2d_rordered(p, "triang_h_s160_20_scaled.out");
|
2018-08-26 19:30:07 +03:00
|
|
|
{
|
|
|
|
points2d_rordered_t v = points2d_rordered_annulus(p, 15, true, 17, true);
|
|
|
|
dump_points2d_rordered(&v, "triang_h_ann_i15-i17.out");
|
|
|
|
v = points2d_rordered_annulus(p, 15, false, 17, true);
|
|
|
|
dump_points2d_rordered(&v, "triang_h_ann_x15-i17.out");
|
|
|
|
v = points2d_rordered_annulus(p, 15, false, 17, false);
|
|
|
|
dump_points2d_rordered(&v, "triang_h_ann_x15-x17.out");
|
|
|
|
v = points2d_rordered_annulus(p, 15, true, 17, false);
|
|
|
|
dump_points2d_rordered(&v, "triang_h_ann_i15-x17.out");
|
|
|
|
}
|
2018-08-23 11:38:58 +03:00
|
|
|
points2d_rordered_free(p);
|
|
|
|
triangular_lattice_gen_free(g);
|
|
|
|
|
|
|
|
|
2018-08-25 01:16:50 +03:00
|
|
|
g = triangular_lattice_gen_init(7, TRIANGULAR_VERTICAL, true,1);
|
2018-08-23 11:38:58 +03:00
|
|
|
triangular_lattice_gen_extend_to_steps(g, 7);
|
2018-08-25 01:16:50 +03:00
|
|
|
dump_points2d_rordered(&(g->ps), "triang_v_plus_s7.out");
|
2018-08-23 11:38:58 +03:00
|
|
|
p = points2d_rordered_scale(&(g->ps), 1/7.);
|
|
|
|
triangular_lattice_gen_free(g);
|
2018-08-25 01:16:50 +03:00
|
|
|
dump_points2d_rordered(p, "triang_v_plus_s7_scaled_out");
|
2018-08-23 11:38:58 +03:00
|
|
|
points2d_rordered_free(p);
|
2018-08-25 01:16:50 +03:00
|
|
|
g = triangular_lattice_gen_init(7, TRIANGULAR_VERTICAL, true,-1);
|
|
|
|
triangular_lattice_gen_extend_to_steps(g, 7);
|
|
|
|
dump_points2d_rordered(&(g->ps), "triang_v_minus_s7.out");
|
|
|
|
p = points2d_rordered_scale(&(g->ps), 1/7.);
|
|
|
|
triangular_lattice_gen_free(g);
|
2018-08-26 19:30:07 +03:00
|
|
|
dump_points2d_rordered(p, "triang_v_minus_s7_scaled.out");
|
2018-08-25 01:16:50 +03:00
|
|
|
points2d_rordered_free(p);
|
|
|
|
|
2018-08-25 12:13:10 +03:00
|
|
|
honeycomb_lattice_gen_t *h = honeycomb_lattice_gen_init_h(1, TRIANGULAR_HORIZONTAL);
|
|
|
|
dump_points2d_rordered(&(h->ps), "hex_h_empty.out");
|
|
|
|
honeycomb_lattice_gen_extend_to_steps(h, 7);
|
|
|
|
dump_points2d_rordered(&(h->ps), "hex_h_s7.out");
|
2018-08-26 22:36:45 +03:00
|
|
|
point2d shift = {0, h->h};
|
|
|
|
p = points2d_rordered_shift(&(h->ps), shift, DBL_EPSILON, h->h * DBL_EPSILON);
|
|
|
|
dump_points2d_rordered(p, "hex_h_s7_shifted.out");
|
|
|
|
points2d_rordered_free(p);
|
2018-08-25 12:13:10 +03:00
|
|
|
honeycomb_lattice_gen_extend_to_steps(h, 120);
|
|
|
|
dump_points2d_rordered(&(h->ps), "hex_h_s120.out");
|
|
|
|
honeycomb_lattice_gen_free(h);
|
|
|
|
|
|
|
|
h = honeycomb_lattice_gen_init_a(1, TRIANGULAR_VERTICAL);
|
|
|
|
honeycomb_lattice_gen_extend_to_steps(h, 5);
|
|
|
|
dump_points2d_rordered(&(h->ps), "hex_v_s5.out");
|
|
|
|
honeycomb_lattice_gen_free(h);
|
|
|
|
|
2018-08-23 11:38:58 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|