zykloid {cycloids} | R Documentation |
Core function for calculating coordinate representations of hypocycloids, epicyloids, hypotrochoids, and epitrochoids (altogether called 'cycloids' here)
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
zykloid(A, a, lambda, hypo = TRUE, steps = 360, start = pi/2)
Arguments
A |
The Radius of the fixed circle |
a |
The radius of the moving circle |
lambda |
The distance of the tracepoint from the moving circle's ( |
hypo |
logical. If TRUE, the resulting figure is a hypocycloid ( |
steps |
positive integer. The number of steps per circuit of the moving
circle ( |
start |
Start angle (radians) of the moving circle's ( |
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
# 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)