56 lines
1.9 KiB
C++
56 lines
1.9 KiB
C++
/// g++ -g -Imodules -std=c++20 task2.cpp task2.misc.cpp task3.cpp task3.misc.cpp task3.test.cpp -o build/task3.exe
|
|
/// ./build/task3.exe
|
|
/// @file
|
|
/// @brief Task3: implementation
|
|
|
|
#include "task3.hpp" // task3::render_something
|
|
|
|
#include "task3.misc.hpp" // task3::render_wrapper
|
|
|
|
#include "task2.hpp" // task2::BBox, task2::Circle, task2::Triangle
|
|
|
|
#include "iue-rnd/random.hpp" // iue::rng::UniformDouble, iue::rng::UniformCircle, iue::rng::UniformTriangle
|
|
|
|
#include <cmath>
|
|
#include <filesystem> // std::filesystem::path
|
|
#include <iostream>
|
|
#include <numbers>
|
|
|
|
/// @todo Include additional standard library headers as needed
|
|
|
|
namespace task3 {
|
|
|
|
/// @todo Implement function 'render_something' as declared and specified in task3.hpp
|
|
/// Implementation Hints:
|
|
/// - You can plot whatever you want, but you need to plot at least 20 primitives!
|
|
/// - You can view .svg-files using your web browser (or installing a VSCode extension to preview SVGs)
|
|
/// - use the provided function 'task3::render_wrapper' from 'task3.misc.hpp' to plot
|
|
/// task2::BBox, task2::Circle, task2::Triangle to a SVG-file
|
|
/// - The idea is that you make use of the functionality (scale/shift/rotate) you implemented in task2
|
|
/// - Optional: you can make use of the random Generators in 'iue-rnd/random.hpp' to obtain random values, circles,
|
|
/// and triangles
|
|
int render_something(std::filesystem::path filepath) {
|
|
|
|
task2::Vec2d min = {0, 0};
|
|
task2::Vec2d max = {1, 2};
|
|
task2::BBox trunk = {min, max};
|
|
task2::Circle leaves = {{0.5,0.5},1};
|
|
std::vector<task2::BBox> bboxes;
|
|
std::vector<task2::Circle> circles;
|
|
std::vector<task2::Triangle> triangles;
|
|
|
|
|
|
for(int i = 0; i < 20; i++){
|
|
double x_trans=3*i;
|
|
bboxes.push_back(trunk.translate({x_trans,0}));
|
|
circles.push_back(leaves.translate({x_trans,2}));
|
|
}
|
|
|
|
auto [bbmin, bbmax] = task3::render_wrapper(filepath, bboxes, circles, triangles);
|
|
|
|
return triangles.size() + bboxes.size() + circles.size();
|
|
};
|
|
|
|
} // namespace task3
|
|
|