Skip to content

Commit 60a8624

Browse files
Fill the lower right sub-plot in 'circle4' by drawing a Ringed Interlacement.
1 parent ee9ca64 commit 60a8624

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ E.g. op, pconic, hconic.
114114
* Convert Tarim's C++ 'spiro' to C and make it use the library too.
115115
* Finish off some of the incomplete plots. E.g. hexagon, fraserspiral,
116116
flake, qrplot, spiralsq, twist, zigzag.
117-
* Fill the empty sub-plots in 'circle4' and 'piscis'.
117+
* Fill the empty sub-plot in 'piscis'.
118118
* Clean up the various 'dala' drawings. Eliminate the 'dala2c' variant
119119
by adding colour to 'dala2.c'.
120120
* Add run-time variation to 'dala2.c'.

circle4.c

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
void circle4(const double x0, const double y0, const double ht);
1212
void circlearcs(const double x0, const double y0, const double ht);
1313
void yinyang(const double x0, const double y0, const double ht, const int n);
14+
void plot_lr(const double xc, const double yc, const double r1, const double r2);
1415
void plot_ur(const double xc, const double yc, const double r1, const double r2);
1516
void rotate(double *x, double *y, const double st, const double ct);
1617

@@ -61,7 +62,8 @@ int main(int argc, char * const argv[])
6162

6263
/* Draw four circle and arc plots */
6364
circle4(w4, h4, maxy / 2.0);
64-
circlearcs(xc + w4, h4, maxy / 2.0);
65+
// circlearcs(xc + w4, h4, maxy / 2.0);
66+
plot_lr(xc + w4, h4, maxx / 5.0, maxy / 5.0);
6567
yinyang(w4, yc + h4, maxy / 2.0, 3);
6668
plot_ur(xc + w4, yc + h4, maxx / 5.0, maxy / 5.0);
6769

@@ -84,6 +86,41 @@ void circle4(const double x0, const double y0, const double ht)
8486
}
8587

8688

89+
void plot_lr(const double xc, const double yc, const double r1, const double r2)
90+
{
91+
/* Inspired by "Handbook of Designs and Devices" by
92+
Clarence P. Hornung, ISBN 0-486-20125-2, page 22,
93+
The Ringed Interlacement, fig. 190 */
94+
const int n = 9;
95+
const double delta = (2.0 * M_PI) / (double)n;
96+
const double degrees = 180.0 + (delta * (180.0 / M_PI));
97+
const double r = r2 * 0.8;
98+
int i;
99+
100+
for (i = 0; i < n; i++) {
101+
const double theta = delta * (double)i;
102+
103+
const double x = r * cos(theta);
104+
const double y = r * sin(theta);
105+
const double xn = r * cos(theta + delta);
106+
const double yn = r * sin(theta + delta);
107+
const double xp = r * cos(theta - delta);
108+
const double yp = r * sin(theta - delta);
109+
const double x1 = (x + xn) / 2.0;
110+
const double y1 = (y + yn) / 2.0;
111+
const double x2 = (x * 0.4) + (xp * 0.6);
112+
const double y2 = (y * 0.4) + (yp * 0.6);
113+
114+
// moveto(xc, yc);
115+
// lineto(xc + x1, yc + y1);
116+
117+
moveto(xc + x2, yc + y2);
118+
arc(xc + x, yc + y, degrees);
119+
arc(xc + x1, yc + y1, 180.0);
120+
}
121+
}
122+
123+
87124
void circlearcs(const double x0, const double y0, const double ht)
88125
{
89126
/* Intersection of circles or arcs:

0 commit comments

Comments
 (0)