Koch curve: Difference between revisions
Content deleted Content added
Added Rust solution |
m Minor edit to C++ code |
||
Line 140:
double x0, y0, x1, y1;
size_t j = 0;
for (size_t i = 0; i + 1 < size; ++i
x0 = points[i].x;
y0 = points[i].y;
Line 147:
double dy = y1 - y0;
double dx = x1 - x0;
output[j++]
output[j++]
output[j
output[j
}
output[j]
return output;
}
Line 169 ⟶ 164:
{x + length/2, y + length * sqrt3_2},
{x + length, y},
{x, y}
};
for (int i = 0; i < iterations; ++i)
Line 180 ⟶ 175:
<< size << "' height='" << size << "'>\n";
out << "<rect width='100%' height='100%' fill='black'/>\n";
out << "<path stroke-width='1' stroke='white' fill='none' d='
auto points(koch_points(size, iterations));
for (size_t i = 0, n = points.size(); i < n; ++i)
▲ out << "L " << points[i].x << ',' << points[i].y << '\n';
out << "z'/>\n</svg>\n";
}
|