Skip to content

Function Mesh

1
fmesh(fn);

example_fmesh_1

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#include <cmath>
#include <matplot/matplot.h>

int main() {
    using namespace matplot;

    fmesh([](double x, double y) { return sin(x) + cos(y); });

    show();
    return 0;
}

More examples

example_fmesh_2

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#include <cmath>
#include <matplot/matplot.h>

int main() {
    using namespace matplot;

    auto r = [](double u, double v) { return 2 + sin(7 * u + 5 * v); };
    auto funx = [r](double u, double v) { return r(u, v) * cos(u) * sin(v); };
    auto funy = [r](double u, double v) { return r(u, v) * sin(u) * sin(v); };
    auto funz = [r](double u, double v) { return r(u, v) * cos(v); };
    fmesh(funx, funy, funz, std::array<double, 4>{0, 2 * pi, 0, pi});

    show();
    return 0;
}

example_fmesh_3

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include <cmath>
#include <matplot/matplot.h>

int main() {
    using namespace matplot;

    fmesh([](double x, double y) { return erf(x) + cos(y); },
          std::array<double, 4>{-5, 0, -5, 5});
    hold(on);
    fmesh([](double x, double y) { return sin(x) + cos(y); },
          std::array<double, 2>{0, 5}, std::array<double, 2>{-5, 5});
    hold(off);

    show();
    return 0;
}

example_fmesh_4

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <cmath>
#include <matplot/matplot.h>

int main() {
    using namespace matplot;

    fmesh([](double x, double y) {
        return sin(x) + cos(y);
    })->edge_color("red");

    show();
    return 0;
}