From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- graphics/epix/samples/levelset2.xp | 72 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 graphics/epix/samples/levelset2.xp (limited to 'graphics/epix/samples/levelset2.xp') 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(); +} + -- cgit v1.2.3