Core function for calculating coordinate representations of hypocycloids, epicyloids, hypotrochoids, and epitrochoids (altogether called 'cycloids' here)

Share:

Description

This is the package's core function for calculating cycloids. These are represented by a set of two-dimensional point coordinates. Although this function provides the essential mathematics, you may want to use the wrappers zykloid.scaleA, zykloid.scaleAa, and zykloid.scaleP due to their convenient scaling and positioning options.

Usage

1
zykloid(A, a, lambda, hypo = TRUE, steps = 360, start = pi/2)

Arguments

A

The Radius of the fixed circle cfix. Must be an integer Number > 0.

a

The radius of the moving circle cmov. Must be an integer Number > 0. Together with A, a determines the resulting cycloid's shape and number of peaks which can be calculated with npeaks.

lambda

The distance of the tracepoint from the moving circle's (cmov) centre in relative units of its radius a. lambda = 1 means that the tracepoint is located on cmov's circumference. For lambda < 1, the tracepoint is on cmov's area, e.g. if lambda = 0.5, it is halfway between cmov's centre and its circumference. If lambda > 1 the tracepoint is outside cmov's area, you might imagine it being attached to a rod which is attached to cmov and crosses its centre. E.g. lambda = 2 would mean that the tracepoint's distance from cmov's centre equals 2*a. lambda = 0 produces a circle because the tracepoint is identical with cmov's centre.

hypo

logical. If TRUE, the resulting figure is a hypocycloid (lambda = 1) or a hypotrochoid (lambda != 1), because cmov is rolling along the inner side of the fixed circle (cfix). If FALSE, an epicycloid (lambda = 1) or an epitrochoid lambda != 1 is generated, as cmov is rolling at the outside of cfix's circumference.

steps

positive integer. The number of steps per circuit of the moving circle (cmov) for which tracepoint positions are calculated. The default, 360, means steps of 1 degree for the movement of cmov. Analogously, steps = 720 would mean steps of 0.5 degrees.

start

Start angle (radians) of the moving circle's (cmov) centre counterclockwise to the horizontal with the fixed circle's (cfix) centre as the pivot. The tracepoint will start at a peak.

Details

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 an 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.
With the arguments of zykloid as defined above, the centre of cfix in the origin, and phi being the counterclockwise angle of cmov's midpoint against the start position with cfix' centre as the pivot, the cartesian coordinates of a point on the cycloid are calculated as follows:

x = (A + a) * cos(phi + start) - lambda * a * cos((A + a)/a * phi + start)
y = (A + a) * sin(phi + start) - lambda * a * sin((A + a)/a * phi + start)

Value

A dataframe with the columns x and y. Each row represents a tracepoint position. The positions are ordered along the trace with the last and the first point being identical in order to warrant a closed figure when plotting the data.

Author(s)

Peter Biber

References

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

See Also

zykloid.scaleA, zykloid.scaleAa, zykloid.scaleP

Examples

 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
# Very simple example
cycl <- zykloid(A = 17, a = 9, lambda = 0.9, hypo = TRUE)
plot(y ~ x, data = cycl, asp = 1, type = "l")


# More complex: Looks like a passion flower
op <- par(mar = c(0,0,0,0), bg = "black")
plot.new()
plot.window(asp = 1, xlim = c(-23, 23), ylim = c(-23, 23))
ll   <- seq(2, 0, -0.2)
ccol <- rep(c("lightblue", "lightgreen", "yellow", "yellow",
              "yellow"), 2)
for (i in c(1:length(ll))) {
     z <- zykloid(A = 15, a = 7, lambda = ll[i], hypo = TRUE)
     lines(y ~ x, data = z, col = ccol[i])
} # for i
par(op)


# Dense hypotrochoids
op <- par(mar = c(0,0,0,0), bg = "black")
plot.new()
plot.window(asp = 1, xlim = c(-1.5, 1.5), ylim = c(-1.5, 1.5))
m <- zykloid(A = 90, a = 89, lambda = 0.01)
lines(y ~ x, data = m, col = "grey")
m <- zykloid(A = 90, a = 89, lambda = 0.02)
lines(y ~ x, data = m, col = "red")
m <- zykloid(A = 90, a = 89, lambda = 0.015)
lines(y ~ x, data = m, col = "blue")
par(op)


# Fragile star
op <- par(mar = c(0,0,0,0), bg = "black")
plot.new()
plot.window(asp = 1, xlim = c(-14, 14), ylim = c(-14, 14))
l.max <- 1.6
l.min <- 0.1
ll <- seq(l.max, l.min, by = -1 * (l.max - l.min)/30)
n  <- length(ll)
ccol <- rainbow(n, start = 2/3, end = 1)
for (i in c(1:n)) {
    m <- zykloid(A = 9, a = 8, lambda = ll[i])
    lines(y ~ x, data = m, type = "l", col = ccol[i])
}  # for i
par(op)