Commit 3d6fd6d3 authored by LEFEBVREJP email's avatar LEFEBVREJP email
Browse files

Further work on chaikins method.

parent c9137829
Pipeline #16067 failed with stages
in 359 minutes and 20 seconds
......@@ -16,9 +16,18 @@ std::vector<std::pair<data_type, data_type>> chaikins(
size_t sequence)
{
std::vector<std::pair<data_type, data_type>> result(control_polygon.size() *
(sequence + 1));
for (size_t si = 0; si < sequence; ++si)
(sequence));
for (size_t pi = 0; pi < control_polygon.size(); pi += 2)
{
std::pair<data_type, data_type> p1 = translate(control_polygon[pi]);
std::pair<data_type, data_type> p2 = translate(control_polygon[pi + 1]);
std::pair<data_type, data_type> qi = std::make_pair(
p1.first * .75 + p2.first * .25, p1.second * .75 + p2.second * .25);
std::pair<data_type, data_type> ri = std::make_pair(
p1.first * .25 + p2.first * .75, p1.second * .25 + p2.second * .75);
result[pi] = qi;
result[pi + 1] = ri;
}
return result;
}
......
......@@ -22,9 +22,17 @@ TEST(RadixChaikins, Simple)
return std::make_pair(10.f * float(point.first),
10.f * float(point.second));
};
std::vector<std::pair<float, float>> result =
std::vector<std::pair<float, float>> results =
chaikins<float>(control_polygon, tranlate);
size_t i = 0;
for (const auto& point : results)
{
std::cout << i << ". [" << point.first << "," << point.second << "]"
<< std::endl;
i++;
}
std::vector<std::pair<float, float>> blessed{
{10.f, 20.f}, {10.f, 30.f}, {10.f, 40.f}, {20.f, 40.f}, {30.f, 40.f},
{40.f, 40.f}, {40.f, 30.f}, {50.f, 30.f}, {60.f, 30.f}, {70.f, 30.f},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment