Using gnuplot (5.4 patchlevel 2 - see script below), I plotted the parametric equation from this Wikipedia entry:
https://en.wikipedia.org/wiki/Cyclocycloid
If the given epicycloid variables R=3, r=1, d=0.5 are used (see below), the result matches that on the Wikipedia page. However, using the hypotrochoid variables R=5, r=-3, d=5 produces a plot that does not match the example (it should be a five-fold symmetric star shape). That it is a circle is suggestive of a technical misunderstanding.
script :
reset
# hypotrochoid:
R=5 ; r=(-3) ; d=5
# epicycloid:
# R=3 ; r=1 ; d=(0.5)
x(t) = (R + r) * cos(t) - d * cos( ( ( R + r ) / ( r ) ) * t )
y(t) = (R + r) * sin(t) - d * sin( ( ( R + r ) / ( r ) ) * t )
set parametric
set size square
plot x(t),y(t)
I suspect I have a fundamental misunderstanding of how gnuplot uses the values, how users provide them, or with parametric plotting. I have tried a number of things to explore this, such as :
-adding or removing parentheses
-expressing -3 as -3.0 (interesting, as it produces a fish-like trace)
-incrementally increasing or decreasing the values
-fractions v. decimals
rewriting the expression with negative signs
putting the negative sign in the expression and changing the expression to positive - this is interesting, but is not matching the expectations.
... generally, the negative value produces results that are unexpected. I have managed to get nice drawings, but they are not producing the result on Wikipedia. I cannot tell if it is the expression, the value, or both - perhaps the Wikipedia article needs more information, or it is a mathematics question. It has me running in... circles.
pos-answer follow-up : notice - the range is unspecified, and gnuplot dutifully produces a plot to, apparently, the default of 2*pi - while clearly, the Wikipedia entry shows the plot needs to be run for 3 cycles to see the symmetric pattern.
This is the "everlasting pitfall" of gnuplot's integer division. Make your input parameters floating point values and everything should be fine.
Script:
Result:
Addition:
Just for completeness: rotating the graph by 90°, by exchanging
cos()
andsin()
and changing the sign ony(t)
. And keeping the graph a square by same x- and y-range.Script:
Result: