Commit 01caf747 authored by LEFEBVREJP email's avatar LEFEBVREJP email
Browse files

Adding documentation and extending the templating to include the poly_type.

parent 952f4eaa
Pipeline #16084 passed with stages
in 8 minutes and 34 seconds
......@@ -14,13 +14,25 @@
namespace radix
{
template <typename data_type>
/**
* @brief chaikins The chaikins curve creation
* The Chaikin method uses ratios of points to create intermediate points.
* This algorithm is known as a corner-cutting algorithm and will create curves
* given sharp edges.
* @param control_polygon - This is the initial set of points with sharps edges
* one wishes to smooth out.
* @param translate - This is a coordinate conversion method that supports
* updating the coordinates
* @param sequence - Sequence allows you to support multiple passes - further
* reducing the sharp edges.
*/
template <typename data_type, typename poly_type>
std::vector<std::pair<data_type, data_type>> chaikins(
const std::vector<std::pair<int, int>>& control_polygon,
std::function<
std::pair<data_type, data_type>(const std::pair<int, int>& point)>
const std::vector<std::pair<poly_type, poly_type>>& control_polygon,
std::function<std::pair<data_type, data_type>(
const std::pair<poly_type, poly_type>& point)>
translate =
[](const std::pair<int, int>& point) {
[](const std::pair<poly_type, poly_type>& point) {
return std::make_pair(data_type(point.first),
data_type(point.second));
},
......
......@@ -8,11 +8,11 @@
namespace radix
{
template <typename data_type>
template <typename data_type, typename poly_type>
std::vector<std::pair<data_type, data_type>> chaikins(
const std::vector<std::pair<int, int>>& control_polygon,
std::function<
std::pair<data_type, data_type>(const std::pair<int, int>& point)>
const std::vector<std::pair<poly_type, poly_type>>& control_polygon,
std::function<std::pair<data_type, data_type>(
const std::pair<poly_type, poly_type>& point)>
translate,
size_t sequence)
{
......
......@@ -23,7 +23,7 @@ TEST(RadixChaikins, Simple)
10.f * float(point.second));
};
std::vector<std::pair<float, float>> results =
chaikins<float>(control_polygon, tranlate);
chaikins<float, int>(control_polygon, tranlate);
std::vector<std::pair<float, float>> blessed{
{10.0f, 22.5f}, {10.0f, 27.5f}, {10.0f, 32.5f}, {10.0f, 37.5f},
......@@ -82,7 +82,7 @@ TEST(RadixChaikins, TwoSequence)
10.f * float(point.second));
};
std::vector<std::pair<float, float>> results =
chaikins<float>(control_polygon, tranlate, 2);
chaikins<float, int>(control_polygon, tranlate, 2);
// for (const auto& point : results)
// {
......
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