Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ct_cantor
- {
- void cantor(
- ct::plot::cairo::plot_2d& plot,
- unsigned long ri,
- unsigned long rn,
- glm::vec3 p0,
- glm::vec3 p1,
- float scale
- ) {
- if (ri >= rn) return;
- glm::vec3 dif = p1 - p0;
- glm::vec3 perp = { -dif.y, dif.x, 0.f };
- glm::vec3 cp0 = p0 + perp * scale;
- glm::vec3 cp1 = p1 + perp * scale;
- glm::vec3 cp2 = cp0 + dif * scale;
- glm::vec3 cp3 = cp1 - dif * scale;
- plot.line(p0, p1, CT_RGBF(1, 1, 0), 4.f);
- plot.line(p0, cp0, CT_RGBF(1, 0, 0), 4.f);
- plot.line(p1, cp1, CT_RGBF(1, 0, 0), 4.f);
- plot.line(cp0, cp2, CT_RGBF(1, 0, 0), 4.f);
- plot.line(cp3, cp1, CT_RGBF(1, 0, 0), 4.f);
- cantor(plot, ri + 1, rn, p0, cp0, scale);
- cantor(plot, ri + 1, rn, p1, cp1, scale);
- cantor(plot, ri + 1, rn, cp0, cp2, scale);
- cantor(plot, ri + 1, rn, cp3, cp1, scale);
- cantor(plot, ri + 1, rn, cp0, p0, scale);
- cantor(plot, ri + 1, rn, cp1, p1, scale);
- cantor(plot, ri + 1, rn, cp2, cp0, scale);
- cantor(plot, ri + 1, rn, cp1, cp3, scale);
- }
- void manifest(ct::plot::cairo::plot_2d& plot)
- {
- std::cout << "ct_cantor::manifest\n\n";
- plot.line({ -1, 0 }, { 1, 0 }, CT_RGBF(1, 0, 0), 4.f);
- cantor(plot, 0, 5, { -1, 0, 0 }, { 1, 1, 0 }, 1.f / 3.f);
- cantor(plot, 0, 5, { 1, 0, 0 }, { -1, -.5, 0 }, 1.f / 3.f);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement