Functions for calculating coordinate representations of hypocycloids, epicyloids, hypotrochoids, and epitrochoids (altogether called 'cycloids' here) with different scaling and positioning options. The cycloids can be visualised with any appropriate graphics function in R.

Package: | cycloids |

Type: | Package |

Version: | 1.0 |

Date: | 2013-10-24 |

License: | GPL-3 |

This package has been written for calculating cartesian coordinate
representations of hypocycloids, epicyloids, hypotrochoids, and
epitrochoids (altogether called 'cycloids' here). These can be
easily visualized with any R graphic routine that
handles two-dimensional data. All examples shown here use
standard R graphics. While there are technical applications, the
main purpose of this package is to create mathematical artwork.

Geometrically, cycloids in the sense of this package are generated as
follows (Figure 1, 2): Imagine a circle *cfix*, with radius
*A*, which is fixed on a plane. Another circle, *cmov*,
with radius *a*, is rolling along *cfix*'s circumference
at the outside of *cfix*. The figure created by the trace of
a point on *cmov*'s circumference is called an epicycloid (Figure 1A).
If *cmov* is rolling not at the outside but at the inside of
*cfix*, the trace of a point on *cmov*'s circumference
is called a hypocycloid (Figure 2A).

If in both cases the tracepoint is not located on
*cmov*'s circumference but at a fixed distance from its midpoint
either in- or outside cmov, the resulting figure is an epitrochoid (Figure 1B, C)
or a hypotrochoid (Figure 2B, C), respectively. Hypotrochoids and epitrochoids
became quite popular through toys like the spirograph.

The most important functions of the package are
`zykloid`

, `zykloid.scaleA`

,
`zykloid.scaleAa`

, and `zykloid.scaleP`

.

Type `demo(cycloids)`

for seeing some examples.

Peter Biber

Maintainer: Peter Biber <castor.fiber@gmx.de>

Bronstein IN, Semendjaev KA, Musiol G, Muehlig H (2001): Taschenbuch der
Mathematik, 5th Edition, Verlag Harri Deutsch, 1186 p. (103 – 105)

http://en.wikipedia.org/wiki/Epicycloid

http://en.wikipedia.org/wiki/Hypocycloid

http://en.wikipedia.org/wiki/Epitrochoid

http://en.wikipedia.org/wiki/Hypotrochoid

http://en.wikipedia.org/wiki/Spirograph

`zykloid`

, `zykloid.scaleA`

,
`zykloid.scaleAa`

, `zykloid.scaleP`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | ```
library(cycloids)
# Create and plot a hypocycloid, a hypotrochoid, an epicycloid,
# and an epitrochoid, all of them with radii A = 5 and a = 3
npeaks(5, 3) # The cycloids will have five peaks
# The hypocycloid
cyc <- zykloid(A = 5, a = 3, lambda = 1, hypo = TRUE)
plot(y ~ x, data = cyc, type = "l", asp = 1, xlim = c(-12, 12),
ylim = c(-12, 12), main = "A = 5, a = 3")
# The hypotrochoid
cyc <- zykloid(A = 5, a = 3, lambda = 1/2, hypo = TRUE)
lines(y ~ x, data = cyc, type = "l", asp = 1, col = "green")
# The epicycloid
cyc <- zykloid(A = 5, a = 3, lambda = 1, hypo = FALSE)
lines(y ~ x, data = cyc, type = "l", col = "red")
# The epitrochoid
cyc <- zykloid(A = 5, a = 3, lambda = 1/2, hypo = FALSE)
lines(y ~ x, data = cyc, type = "l", col = "blue")
legend("topleft", c("hypocycloid", "hypotrochoid", "epicycloid",
"epitrochoid"), lty = rep("solid", 4),
col = c("black", "green", "red", "blue"), bty = "n")
# Same Framework, different shape: A = 17, a = 5
npeaks(17, 5) # The cycloids will have seventeen peaks
# The hypocycloid
cyc <- zykloid(A = 17, a = 5, lambda = 1, hypo = TRUE)
plot(y ~ x, data = cyc, type = "l", asp = 1, xlim = c(-27, 27),
ylim = c(-27, 27), main = "A = 17, a = 5")
# The hypotrochoid
cyc <- zykloid(A = 17, a = 5, lambda = 1/2, hypo = TRUE)
lines(y ~ x, data = cyc, type = "l", asp = 1, col = "green")
# The epicycloid
cyc <- zykloid(A = 17, a = 5, lambda = 1, hypo = FALSE)
lines(y ~ x, data = cyc, type = "l", col = "red")
# The epitrochoid
cyc <- zykloid(A = 17, a = 5, lambda = 1/2, hypo = FALSE)
lines(y ~ x, data = cyc, type = "l", col = "blue")
legend("topleft", c("hypocycloid", "hypotrochoid", "epicycloid",
"epitrochoid"), lty = rep("solid", 4),
col = c("black", "green", "red", "blue"), bty = "n")
# Pretty - a classic Spirograph pattern with the same settings
# for A (5) and a (3) as in the first example.
# Varying parameters (here: lambda) within a loop often gives
# nice results.
op <- par(mar = c(0,0,0,0)) # no plot margins
lambdax <- seq(0.85, by = -0.05, length.out = 14)
ccol <- rep(c("blue", "blue", "red", "red"), 4)
plot.new()
plot.window(asp = 1, xlim = c(-4.5, 4.5), ylim = c(-4.5, 4.5))
# draw fourteen hypotrochoids with decreasing lambda
for (i in c(1:14)) {
z <- zykloid(5, 3, lambdax[i])
lines(y ~ x, data = z, type = "l", col = ccol[i])
} # for i
par(op) # set graphics parameters back to original values
# A bit more of the same kind to get the big picture...
op <- par(mar = c(0,0,0,0)) # no plot margins
lambdax <- seq(1, by = -0.05, length.out = 16)
ccol <- rep(c("blue", "blue", "red", "red"), 4)
plot.new()
plot.window(asp = 1, xlim = c(-11, 11), ylim = c(-11, 11))
# first loop: sixteen epitrochoids with decreasing lambda
for (i in 1:16) {
z <- zykloid(5, 3, lambdax[i], hypo = FALSE)
lines(y ~ x, data = z, type = "l", col = ccol[i])
} # for i - first loop
# first loop: sixteen epitrochoids with decreasing lambda
for (i in 1:16) {
z <- zykloid(5, 3, lambdax[i], hypo = TRUE)
lines(y ~ x, data = z, type = "l", col = ccol[i])
} # for i - second loop
par(op) # set graphics parameters back to original values
# Show off with an example for zykloid.scaleP
# No plot margins, and ... paint it black
op <- par(mar = c(0,0,0,0), bg = "black")
lambdax <- seq(2, 0.0, -0.05) # Note: some lambdas are greater than 1
ccol <- rep(c("lightblue", "lightblue", "yellow", "yellow", "yellow"), 9)
plot.new()
plot.window(asp = 1, xlim = c(-1, 1), ylim = c(-1, 1))
for (ll in c(1:length(lambdax))) {
z <- zykloid.scaleP(A = 7, a = 5, hypo = TRUE, lambda = lambdax[ll])
lines(y ~ x, data = z, col = ccol[ll])
} # for ll
par(op) # set graphics parameters back to original values
# Spiky Flower with zykloid.scaleA and zykloid
op <- par(mar = c(0,0,0,0), bg = "black")
plot.new()
plot.window(asp = 1, xlim = c(-150, 150), ylim = c(-150, 150))
z <- zykloid.scaleA(A = 90, a = 32, lambda = 1, Radius = 150, hypo = TRUE)
lines(y ~ x, data = z, col = "lightblue")
for (ll in seq(2, 0.8, -0.4)) {
if (ll == 2) ccol <- "royalblue"
else ccol <- "plum"
z <- zykloid(A = 90, a = 32, lambda = ll, hypo = TRUE, steps = 360, start = pi/2)
lines(y ~ x, data = z, col = ccol)
} # for ll
par(op)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.