summaryrefslogtreecommitdiff
path: root/graphics/epix/samples/mirrorball.flx
blob: 858ee4e9047eb8560b1312907f908ff4cd1ecb49 (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
88
89
90
91
92
93
/* -*-ePiX-*- */
#include "epix.h"
using namespace ePiX;

const double r_0(1); //0.75;
const double golden(0.5*(1+sqrt(5)));

Sphere S0(P(0,0,0), sqrt(3));

Sphere S1(P( 1, golden, 0), r_0);
Sphere S2(P(-1, golden, 0), r_0);
Sphere S3(P( 1,-golden, 0), r_0);
Sphere S4(P(-1,-golden, 0), r_0);

Sphere S5(P( 0, 1, golden), r_0);
Sphere S6(P( 0,-1, golden), r_0);
Sphere S7(P( 0, 1,-golden), r_0);
Sphere S8(P( 0,-1,-golden), r_0);

Sphere S9(P( golden, 0, 1), r_0);
Sphere Sa(P( golden, 0,-1), r_0);
Sphere Sb(P(-golden, 0, 1), r_0);
Sphere Sc(P(-golden, 0,-1), r_0);

Circle C1(S0*S1);
Circle C2(S0*S2);
Circle C3(S0*S3);
Circle C4(S0*S4);
Circle C5(S0*S5);
Circle C6(S0*S6);
Circle C7(S0*S7);
Circle C8(S0*S8);
Circle C9(S0*S9);
Circle Ca(S0*Sa);
Circle Cb(S0*Sb);
Circle Cc(S0*Sc);

// bold circle if facing camera, otherwise plain
void sphere_draw(const Circle& C)
{
  if ((C.center()|camera.viewpt()) >= 0)
    bold();
  else plain();

  C.draw();
}

void icosa()
{
  // S0.draw();
  sphere_draw(C1);
  sphere_draw(C2);
  sphere_draw(C3);
  sphere_draw(C4);
  sphere_draw(C5);
  sphere_draw(C6);
  sphere_draw(C7);
  sphere_draw(C8);
  sphere_draw(C9);
  sphere_draw(Ca);
  sphere_draw(Cb);
  sphere_draw(Cc);
}

int main(int argc, char* argv[])
{
  if (argc == 3)
    {
      char* arg;
      double temp1, temp2;
      temp1=strtod(argv[1], &arg);
      temp2=strtod(argv[2], &arg);

      tix()=temp1/temp2;
    }

  picture(P(-2,-2),P(2,2), "6x6in");

  begin();
  set_crop();
  revolutions();

  // draw frames
  camera.at(sph(12, 0.5*tix(), 0.05));
  red(-1.4); // nearly cyan
  icosa();

  camera.at(sph(12, 0.01+0.5*tix(), 0.05));
  red(1.4);
  icosa();

  end();
}