xvolume

  • Based on ipyvolume by @maartenbreddels

In [ ]:
#include "/home/wolfv/Programs/xvolume/include/xvolume/xvolume_figure.hpp"

In [ ]:
std::vector<float> xs = std::vector<float>({0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1});
auto ys = xs;
std::vector<float> zs = std::vector<float>({0, 0.3, 0.1, 0.6, 0.4, 0.1, 0.6, 0.7, 0.8, 0.9, 1});

In [ ]:
xvl::scatter s;

In [ ]:
s.x = xs;
s.y = ys;
s.z = zs;
s.color = "blue";

In [ ]:
xvl::volume_figure fig1;
fig1

In [ ]:
fig1.scatters = std::vector<xvl::scatter>({s});

In [ ]:
fig1.scatters()[0].color = "red"

In [ ]:
fig1.scatters()[0].connected = false

In [ ]:
fig1.scatters()[0].geo = "cat"

In [ ]:
fig1.scatters()[0].x = std::vector<float>({0.3, 1, 0.4, 0.5, 0.2, 0.9,  0.2, 0.9, 0.1, 0.2});

In [ ]:
fig1.scatters()[0].geo = "diamond"

In [ ]:
std::vector<float> many_x(10000), many_y(10000), many_z(10000);

In [ ]:
for (int i = 0; i < 10000; ++i)
{
    many_x[i] = std::sin(i * 0.5) + 0.5;
    many_y[i] = std::cos(i * 0.5) + 0.5;
    many_z[i] = i * 0.001f;
}

In [ ]:
fig1.scatters()[0].x = many_x;
fig1.scatters()[0].y = many_y;
fig1.scatters()[0].z = many_z;

Parametric mesh plots


In [ ]:
xvl::mesh m;

In [ ]:
xvl::fill_mesh(m, [](auto x, auto y) { return (x*x + y*y) / 5.0; },
               {40, 40}, {-3, 3}, {-3, 3}, true)

In [ ]:
xvl::volume_figure fig;
fig

In [ ]:
fig.xlim = std::array<double, 2>({-3, 3});
fig.ylim = std::array<double, 2>({-3, 3});
fig.zlim = std::array<double, 2>({-3, 3});

In [ ]:
fig.meshes = std::vector<xvl::mesh>({m});

In [ ]:
xvl::fill_mesh(m, [](auto x, auto y) { return std::sin(x) + std::cos(y); },
               {40, 40}, {-3, 3}, {-3, 3}, true)

In [ ]:
fig.meshes = std::vector<xvl::mesh>({m});

In [ ]:
fig.meshes()[0].color = "green"

In [ ]: