Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Functions | |
template<std::size_t N> | |
void | spirograph (std::array< std::pair< double, double >, N > *points, double l, double k, double rot) |
void | test () |
Test function to save resulting points to a CSV file. | |
Functions related to spirograph.cpp
void spirograph::spirograph | ( | std::array< std::pair< double, double >, N > * | points, |
double | l, | ||
double | k, | ||
double | rot ) |
Generate spirograph curve into arrays x
and y
such that the i^th point in 2D is represented by (x[i],y[i])
. The generating function is given by:
\begin{eqnarray*} x &=& R\left[ (1-k) \cos (t) + l\cdot k\cdot\cos \left(\frac{1-k}{k}t\right) \right]\\ y &=& R\left[ (1-k) \sin (t) - l\cdot k\cdot\sin \left(\frac{1-k}{k}t\right) \right] \end{eqnarray*}
where
Since we are considering ratios, the actual values of \(r\) and \(R\) are immaterial.
N | number of points = size of array |
[out] | points | Array of 2D points represented as std::pair |
l | the relative distance of marker from the centre of inner circle and \(0\le l\le1\) | |
k | the ratio of radius of inner circle to outer circle and \(0<k<1\) | |
rot | the number of rotations to perform (can be fractional value) |
void spirograph::test | ( | ) |
Test function to save resulting points to a CSV file.