summaryrefslogtreecommitdiff
path: root/graphics/epix/samples/trig.flx
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/trig.flx
Initial commit
Diffstat (limited to 'graphics/epix/samples/trig.flx')
-rw-r--r--graphics/epix/samples/trig.flx74
1 files changed, 74 insertions, 0 deletions
diff --git a/graphics/epix/samples/trig.flx b/graphics/epix/samples/trig.flx
new file mode 100644
index 0000000000..f07763f4d4
--- /dev/null
+++ b/graphics/epix/samples/trig.flx
@@ -0,0 +1,74 @@
+/* -*-ePiX-*- */
+#include "epix.h"
+using namespace ePiX;
+
+P f(double x, double t)
+{
+ return P(x, Sin(x+t));
+}
+
+domain R(P(0,0), P(1,1), mesh(60,24), mesh(120, 72));
+
+int main(int argc, char* argv[])
+{
+ if (argc == 3)
+ {
+ char* arg;
+ double temp1, temp2;
+ temp1=strtod(argv[1], &arg);
+ temp2=strtod(argv[2], &arg);
+
+ tix()=temp1/temp2;
+ }
+
+ picture(P(0,0), P(5,2), "5x2in");
+
+ begin();
+ revolutions();
+
+ border();
+ set_crop();
+
+ screen rolling(P(-1,-1), P(1,1));
+ screen waving(P(0,-1), P(1,1));
+
+ activate(rolling);
+
+ P ctr(polar(0.5, tix()));
+ P rim(polar(0.5, tix()) + polar(0.5, -tix()));
+ P rim2(polar(0.5, tix()) + polar(0.5, 0.5-tix()));
+
+ circle(ctr, 0.5); // small wheel
+
+ bold();
+ circle(P(0,0), 1); // big wheel
+
+ green();
+ line(P(1,0), P(-1,0));
+
+ blue();
+ line(P(0,1), P(0,-1));
+
+ red();
+ line(ctr, rim);
+ line(ctr, rim2);
+
+ ddot(rim);
+ ddot(rim2);
+ deactivate(rolling);
+
+ activate(waving);
+ set_crop();
+ blue();
+ plot(f, R.slice2(tix()));
+ deactivate(waving);
+
+ inset(rolling, P(0,0), P(2,2));
+ inset(waving, P(3,0), P(5,2));
+
+ dashed();
+ pen(Blue(1.6), 0.15);
+ line(P(1,1+Sin(tix())), P(3,1) + f(0, tix()));
+
+ end();
+}