From 95361c8c2229840a5e05f49622be629cf654371d Mon Sep 17 00:00:00 2001 From: NPScript Date: Thu, 18 Aug 2022 17:04:05 +0200 Subject: first sketch --- example.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 example.c (limited to 'example.c') 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 +#include + +#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; +} -- cgit v1.2.3-70-g09d2