summaryrefslogtreecommitdiff
path: root/graphics/epix/samples/spherical.xp
blob: c40b897e8fca8b4b356a4aa2d369f732740df231 (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
/* -*-ePiX-*- */
#include "epix.h"
using namespace ePiX;

const double MAX(3);

int main()
{
  picture(P(-MAX,-MAX),P(MAX,MAX), "6x6in");

  begin();
  camera.at(30,5,20);

#ifdef GRAY
  camera.filter(Gray_Neutral());
#endif
  revolutions();

  domain R(P(0,0,-0.25), P(3,1,0.25), mesh(12, 48, 24), mesh(12, 96, 120));
 
  std::list<domain> cuts;

  double Phi(7.0/48), Theta(7.0/48);

  cuts.push_back(R.slice1(2));
  cuts.push_back(R.slice2(0));
  cuts.push_back(R.slice2(Theta));
  cuts.push_back(R.slice3(0));
  cuts.push_back(R.slice3(Phi));

  plain(Black(0.5));
  fill(Red(1.9));
  scenery coords(sph, R.slice1(2)); //  rho = 2

  fill(Yellow(0.35));
  coords.add(sph, R.slice2(0)).add(sph, R.slice2(Theta)); // theta = 0, Theta

  fill(Blue(1.9));
  coords.add(sph, R.slice3(0)).add(sph, R.slice3(Phi)); // phi = 0, Phi

  coords.draw();
  //  surface(sph, cuts);
  fill(false);

  pen(Black());
  base(White(), "1.2pt");
  arrow_fill(1);
  arrow(P(3,0,0), P(3.5,0,0));
  label(P(3.5,0,0), P(-2,-2), "$x$", bl);

  arrow(P(0,3,0), P(0,3.5,0));
  label(P(0,3.5,0), P(2,-2), "$y$", br);

  arrow(P(0,0,3), P(0,0,3.5));
  label(P(0,0,3.5), P(0,4), "$z$", t);

  bold();
  arc_arrow(P(0,0,0), 2, 0.5*Theta, Theta);
  arc_arrow(P(0,0,0), 2, 0.5*Theta, 0);

  aarrow(P(0,0,0), sph(2, Theta, Phi));

  label(sph(2, 0.5*Theta, 0), P(2,2), "$\\theta$", t);
  label(sph(2, Theta, 0.5*Phi), P(-2,0), "$\\phi$", l);
  label(sph(1, Theta, Phi), P(2,-2), "$\\rho$", br);

  base(Neutral(), 0);
  dashed();
  plain();
  line(P(0,0,0), P(2,0,0));
  line(P(0,0,0), sph(2, Theta, 0));
  line(P(0,0,0), sph(2, Theta, Phi));

  pst_format();
  end();
}