Sierpinski curve: Difference between revisions
Content added Content deleted
m (Minor edit) |
m (Minor edit) |
||
Line 28: | Line 28: | ||
double theta = (pi * angle)/180.0; |
double theta = (pi * angle)/180.0; |
||
x += length * std::cos(theta); |
x += length * std::cos(theta); |
||
y |
y -= length * std::sin(theta); |
||
out << 'L' << x << ',' << y << '\n'; |
out << 'L' << x << ',' << y << '\n'; |
||
} |
} |
||
Line 39: | Line 39: | ||
line(out, x, y, length, angle); |
line(out, x, y, length, angle); |
||
else if (c == '+') |
else if (c == '+') |
||
⚫ | |||
⚫ | |||
angle = (angle + 45) % 360; |
angle = (angle + 45) % 360; |
||
⚫ | |||
⚫ | |||
} |
} |
||
} |
} |
||
Line 48: | Line 48: | ||
const int size = 545; |
const int size = 545; |
||
const int order = 5; |
const int order = 5; |
||
const double x = |
const double x = 5, y = 10, length = 7; |
||
std::ofstream out("sierpinski_curve.svg"); |
std::ofstream out("sierpinski_curve.svg"); |
||
if (!out) { |
if (!out) { |