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

const double k(2*M_PI/(360*sqrt(3))); // assume "degrees" mode

double exp_cos(double t) { return exp(k*t)*Cos(t); }
double exp_sin(double t) { return exp(k*t)*Sin(t); }
double minus_exp_cos(double t) { return -exp_cos(t); }
double minus_exp_sin(double t) { return -exp_sin(t); }

int main()
{
  picture(P(-1,-1), P(1,1), "2.5 x 2.5in");

  begin();
  degrees(); // set angle units
  camera.at(P(1, 2.5, 3));

  sphere(); // draw unit sphere's horizon

  pen(Blue(1.6)); // hidden portions of loxodromes
  backplot_N(exp_cos, exp_sin, -540, 540, 180);
  backplot_N(minus_exp_cos, minus_exp_sin, -540, 540, 180);

  pen(Red(1.6));
  backplot_N(exp_sin, minus_exp_cos, -540, 540, 180);
  backplot_N(minus_exp_sin, exp_cos, -540, 540, 180);

  pen(Black(0.3)); // coordinate grid

  for (int i=0; i<=12; ++i) {
    latitude(90-15*i, 0, 360);
    longitude(30*i, 0, 360);
  }

  bold(Blue()); // visible portions of loxodromes
  frontplot_N(exp_cos, exp_sin, -540, 540, 360);
  frontplot_N(minus_exp_cos, minus_exp_sin, -540, 540, 360);

  pen(Red());
  frontplot_N(exp_sin, minus_exp_cos, -540, 540, 360);
  frontplot_N(minus_exp_sin, exp_cos, -540, 540, 360);

  end();
}