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

// ODE parameters
const double A1(10);
const double A2(28);
const double A3(2.6666);

// parameter box
const double MAX(30);

// bounding box (set in screens)
const double XMAX(50);

// flow time
const double TMAX(2000);

P F(double x, double y, double z)
{
  return 0.01*P(A1*(y-x), x*(A2-z)-y, x*y-A3*z);
}

domain R(P(-MAX,-MAX,0), P(MAX,MAX,2*MAX), mesh(6, 6, 6));

void draw_frame()
{
  dart_field(F, R.resize1(0,MAX), 0.5);

  bold(Red());
  ode_plot(F, P(10,0,0), 0, TMAX, TMAX);

  pen(Blue());
  // nearby start points, but trajectories not close
  ode_plot(F, P(10.5,0,0), 0, TMAX, TMAX);

  plain(Black());
  dart_field(F, R.resize1(-MAX,0), 0.5);
}

// initialize the camera
void init_cam(const P& arg)
{
  camera.at(arg);
  camera.look_at(P(0,0,MAX));
  camera.range(500);
}

int main()
{
  picture(P(-1,0), P(1,1), "6x3in");

  begin();

  screen  left_eye(P(-XMAX,-XMAX), P(XMAX,XMAX));
  activate(left_eye);
  init_cam(P(-100, 90, 63));
  draw_frame();

  screen right_eye(P(-XMAX,-XMAX), P(XMAX,XMAX));
  activate(right_eye);
  init_cam(P(-100, 80, 63));
  draw_frame();

  // page layout
  inset(left_eye, P(0,0), P(1,1));
  inset(right_eye, P(-1,0), P(0,1));

  end();
}