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

const int MAX(24);
const double x0(4);
const double ht(3); // camera height
const double INFTY(100000);

P f(double t)
{
  return P(t, t*t, 0);
}

int main() 
{
  picture(P(-3,-3),P(3,3), "4x4in");

  begin();

  border();
  set_crop();

  viewpoint(0,-ht*ht, ht);
  camera.look_at(P(0,0,1));

  pen(Black(0.3), "0.1pt");
  grid(P(-MAX,0), P(MAX, MAX*MAX), MAX, MAX*MAX/8);
  grid(P(-MAX, 0, 2*ht), P(MAX, MAX*MAX, 2*ht), MAX, MAX*MAX/8);

  pen(Blue(1.4));
  envelope(f, -MAX/2, MAX/2, 20); // envelope of tangent lines


  bbold(Blue());
  Line(P(-100, INFTY, 0), P(100, INFTY, 0));

  masklabel(P(0,0), P(0,2), "$(0,0)$", t);
  label(P(0,INFTY), P(0,-2), "$(0,\\infty)$", b);
  label(P(-0.25*INFTY,INFTY), P(0, 2), "Horizon", t);

  masklabel(P(x0, x0*x0), P(-4,0), "$y=x^2$", l);

  box(P(0,0));
  box(P(0,INFTY));

  pen(1);
  plot(f, -MAX, MAX, 240);

  camera.at(0,0,1000);
  masklabel(P(0, ymin()), P(0,0), 
	"Projective equivalence of a parabola and a circle", t);

  end();
}