summaryrefslogtreecommitdiff
path: root/graphics/epix/samples/symmetries.xp
blob: bda649bdbf63d4d149c1860a8a924a64dfae7af8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* -*-ePiX-*- */
#include "epix.h"
using namespace ePiX;

// draw a regular n-gon with labeled vertices
void polygon(int n, double th_0 = 0)
{
  const double d_th(full_turn()/n);
  path poly;
  for (int i=0; i<n; ++i)
    {
      // i-th vertex
      double th(th_0 + i*d_th);
      const P vtx(cis(th));
      poly.pt(vtx);

      // set label angle
      label_angle(th + 0.25*full_turn());

      // draw label
      std::stringstream buf;
      buf << "$" << i << "$";
      dot(vtx, -8*vtx, buf.str());
    }

  poly.close().draw();
}

int main()
{
  picture(P(0,0), P(2,3), "4 x 6in");

  begin();

  border();

  // draw one hexagon in a screen
  screen scr(P(-1,-1), P(1,1));
  activate(scr);

  polygon(6);

  // marks to distinguish a vertex and orientation
  spot(P(1,0));
  black(0.3);
  line(P(-0.75,0), P(0.75,0));

  black();
  arc_arrow(P(0,0), 0.75, 0, M_PI/3);
  arc_arrow(P(0,0), 0.75, 2*M_PI/3, M_PI);
  arc_arrow(P(0,0), 0.75, 4*M_PI/3, 5*M_PI/3);
  scr.scale(0.9);

  // use layout and affine maps to draw symmetries
  inset(P(0,2), P(1,3));

  scr.rotate(2*M_PI/3);
  inset(P(0,1), P(1,2));

  scr.rotate(2*M_PI/3);
  inset(P(0,0), P(1,1));

  scr.rotate(2*M_PI/3).reflect(0);
  inset(P(1,2), P(2,3));

  scr.rotate(2*M_PI/3);
  inset(P(1,1), P(2,2));

  scr.rotate(2*M_PI/3);
  inset(P(1,0), P(2,1));

  deactivate(scr);

  // label insets
  font_size("LARGE");
  label_angle(0);
  masklabel(P(0.5, 2.5), "$e$");
  masklabel(P(0.5, 1.5), "$\\alpha$");
  masklabel(P(0.5, 0.5), "$\\alpha^2$");

  masklabel(P(1.5, 2.5), "$\\beta$");
  masklabel(P(1.5, 1.5), "$\\beta\\alpha^2$");
  masklabel(P(1.5, 0.5), "$\\beta\\alpha$");

  pst_format();
  end();
}