Skip to content

Commit

Permalink
Fill the lower right sub-plot in 'circle4' by drawing a Ringed Interl…
Browse files Browse the repository at this point in the history
…acement.
  • Loading branch information
anachrocomputer committed Sep 13, 2020
1 parent ee9ca64 commit 60a8624
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ E.g. op, pconic, hconic.
* Convert Tarim's C++ 'spiro' to C and make it use the library too.
* Finish off some of the incomplete plots. E.g. hexagon, fraserspiral,
flake, qrplot, spiralsq, twist, zigzag.
* Fill the empty sub-plots in 'circle4' and 'piscis'.
* Fill the empty sub-plot in 'piscis'.
* Clean up the various 'dala' drawings. Eliminate the 'dala2c' variant
by adding colour to 'dala2.c'.
* Add run-time variation to 'dala2.c'.
Expand Down
39 changes: 38 additions & 1 deletion circle4.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
void circle4(const double x0, const double y0, const double ht);
void circlearcs(const double x0, const double y0, const double ht);
void yinyang(const double x0, const double y0, const double ht, const int n);
void plot_lr(const double xc, const double yc, const double r1, const double r2);
void plot_ur(const double xc, const double yc, const double r1, const double r2);
void rotate(double *x, double *y, const double st, const double ct);

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

/* Draw four circle and arc plots */
circle4(w4, h4, maxy / 2.0);
circlearcs(xc + w4, h4, maxy / 2.0);
// circlearcs(xc + w4, h4, maxy / 2.0);
plot_lr(xc + w4, h4, maxx / 5.0, maxy / 5.0);
yinyang(w4, yc + h4, maxy / 2.0, 3);
plot_ur(xc + w4, yc + h4, maxx / 5.0, maxy / 5.0);

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


void plot_lr(const double xc, const double yc, const double r1, const double r2)
{
/* Inspired by "Handbook of Designs and Devices" by
Clarence P. Hornung, ISBN 0-486-20125-2, page 22,
The Ringed Interlacement, fig. 190 */
const int n = 9;
const double delta = (2.0 * M_PI) / (double)n;
const double degrees = 180.0 + (delta * (180.0 / M_PI));
const double r = r2 * 0.8;
int i;

for (i = 0; i < n; i++) {
const double theta = delta * (double)i;

const double x = r * cos(theta);
const double y = r * sin(theta);
const double xn = r * cos(theta + delta);
const double yn = r * sin(theta + delta);
const double xp = r * cos(theta - delta);
const double yp = r * sin(theta - delta);
const double x1 = (x + xn) / 2.0;
const double y1 = (y + yn) / 2.0;
const double x2 = (x * 0.4) + (xp * 0.6);
const double y2 = (y * 0.4) + (yp * 0.6);

// moveto(xc, yc);
// lineto(xc + x1, yc + y1);

moveto(xc + x2, yc + y2);
arc(xc + x, yc + y, degrees);
arc(xc + x1, yc + y1, 180.0);
}
}


void circlearcs(const double x0, const double y0, const double ht)
{
/* Intersection of circles or arcs:
Expand Down

0 comments on commit 60a8624

Please sign in to comment.