aboutsummaryrefslogtreecommitdiff
path: root/example.c
diff options
context:
space:
mode:
authorNPScript <nathan@reinerweb.ch>2022-08-18 17:04:05 +0200
committerNPScript <nathan@reinerweb.ch>2022-08-18 17:04:05 +0200
commit95361c8c2229840a5e05f49622be629cf654371d (patch)
tree280a6d7706b349563959852057e1741f846d5f60 /example.c
first sketch
Diffstat (limited to 'example.c')
-rw-r--r--example.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/example.c b/example.c
new file mode 100644
index 0000000..af16110
--- /dev/null
+++ b/example.c
@@ -0,0 +1,74 @@
+#include <math.h>
+#include <stdio.h>
+
+#define PI 3.141592653
+
+#include "gragl.h"
+
+Scalar sin_scalar(double x) {
+ Scalar y = {
+ .v = sin(x),
+ .valid = 1
+ };
+
+ return y;
+}
+
+Scalar cos_scalar(double x) {
+ Scalar y = {
+ .v = cos(x),
+ .valid = 1
+ };
+
+ return y;
+}
+
+Scalar tan_scalar(double x) {
+ Scalar y = {
+ .v = tan(x),
+ .valid = 1
+ };
+
+ return y;
+}
+
+Scalar sincos_scalar(double x) {
+ Scalar y = {
+ .v = sin(x) * cos(x) * cos(x) * cos(x) * x,
+ .valid = 1
+ };
+
+ return y;
+}
+
+int main() {
+ Plot2d sin_plot;
+ sin_plot.func = sin_scalar;
+ sin_plot.from = -1;
+ sin_plot.to = 5;
+ sin_plot.step = 0.001;
+
+ Plot2d cos_plot;
+ cos_plot.func = cos_scalar;
+ cos_plot.from = -1;
+ cos_plot.to = 5;
+ cos_plot.step = 0.001;
+
+ Plot2d tan_plot;
+ tan_plot.func = tan_scalar;
+ tan_plot.from = -1;
+ tan_plot.to = 5;
+ tan_plot.step = 0.001;
+
+ Plot2d sincos_plot;
+ sincos_plot.func = sincos_scalar;
+ sincos_plot.from = 0;
+ sincos_plot.to = 100;
+ sincos_plot.step = 0.01;
+
+ Plot2dGroup * group = create_plot2d_group(4, sin_plot, cos_plot, tan_plot, sincos_plot);
+ plot(group);
+ free_plot2d_group(group);
+
+ return 0;
+}