summaryrefslogtreecommitdiff
path: root/graphics/epix/samples/levelset2.xp
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/epix/samples/levelset2.xp
Initial commit
Diffstat (limited to 'graphics/epix/samples/levelset2.xp')
-rw-r--r--graphics/epix/samples/levelset2.xp72
1 files changed, 72 insertions, 0 deletions
diff --git a/graphics/epix/samples/levelset2.xp b/graphics/epix/samples/levelset2.xp
new file mode 100644
index 0000000000..ab1a605069
--- /dev/null
+++ b/graphics/epix/samples/levelset2.xp
@@ -0,0 +1,72 @@
+/* -*-ePiX-*- */
+#include "epix.h"
+using namespace ePiX;
+
+// Style parameters
+const int MAX(1); // maximum coordinate
+
+domain R(P(-MAX,-MAX), P(MAX, MAX), (24, 24), mesh(72,72));
+
+const double sqrt3(sqrt(3));
+
+// function to be graphed
+P f(double x, double y)
+{
+ return P(x, y, 0.75*y*(y-sqrt3*x)*(y+sqrt3*x));
+}
+
+P color(double u, double v, double w)
+{
+ return P(-0.5*w, 0.25*w, 0.95*w);
+}
+
+int main()
+{
+ picture(P(-2*MAX,-2*MAX), P(2*MAX,2*MAX), "6 x 6in");
+
+ begin();
+
+ border(Green(0.6), "1pt");
+ backing(Black());
+
+ camera.at(sph(4*MAX, M_PI/6, M_PI/6));
+
+ // positioned for viewpt in first orthant
+ yellow();
+ grid(P(-MAX,-MAX,-MAX), P(MAX,MAX,-MAX), 4, 4);
+ grid(P(-MAX,-MAX,-MAX), P(MAX,-MAX,MAX), 4, 4);
+ grid(P(-MAX,-MAX,-MAX), P(-MAX,MAX,MAX), 4, 4);
+
+ axis Ax(P(-MAX,-MAX,MAX), P(MAX,-MAX,MAX), 4, P(0,6), t);
+ axis Ay(P(MAX,-MAX,-MAX), P(MAX,MAX,-MAX), 4, P(-2,-2), bl);
+ axis Az(P(MAX,-MAX,-MAX), P(MAX,-MAX,MAX), 4, P(-2,-2), bl);
+
+ Ax.frac().draw();
+ Ay.frac().draw();
+ Az.frac().draw();
+
+ clip_box(P(MAX,MAX,MAX));
+
+ // wire mesh surface
+ plain(Green());
+ plot(f, R);
+
+ // level bands
+ plain(Red());
+
+ for (int i=-5; i <=5; ++i)
+ {
+ clip_slice(P(0,0,0.2*i), P(0,0,1), 0.1);
+#ifdef FLATFILL
+ fill(RGB(0.25+0.1*i, 0, -0.1*i)); // index-dependent coloring
+ surface(f, R);
+#else
+ surface(f, R, color); // domain- or position-dependent coloring
+#endif
+ clip_restore(); // remove temporary slicing planes, keep clip box
+ }
+
+ pst_format();
+ end();
+}
+