eternith15 wrote:Also,tulamide, perhaps you can write out the algorithm you have in mind in more detail in english step by step, and we might all have a go at it.
Well, the algo already exists. But only for graphics. I created a spline class some time ago, you can download it here:
http://flowstone.guru/downloads/ruby-for-flowstone-expansion-spline-class/#description Make sure to read the included manual, it describes some of the concept. Then have a look at the Ruby code. But I will talk about it here in more depth:
The spline class draws bezier curves. The splines are defined by nodes. Each node has two control points, one to control the incoming line and one to control the outgoing line. So far so known. But to actually draw the curves, a technique must be used. This is mine.
Initially you set a maximum number of possible segments per curve (the part between two nodes). Then, the algorithm checks the linear length between two nodes and the curvyness (guessed by the position of the control points, not actually calculated) and based on that decides for a number of segments. The curve between the two nodes is then divided into those segments, and each segment is drawn as a simple line. The segment points on the curve are calculated with cubic interpolation. Instead of polynomials it uses a simplified method, based on the fact that two nested linear interpolations correspond to a quadratic interpolation, and two nested quadratic interpolations correspond to a cubic interpolation.
If we think in terms of an oscillator, the segments are nothing else than ramps, were time equals the x-ordinate and amplitude the y-ordinate. So, all there is to get it going would be to calculate cubic interpolation points and then ramp between those points. And all the segments are controlled by just two nodes. This offers a wide range of applications. For example, a table of just 3 (actually 4, but the last one is the first of the next cycle) predefined nodes can describe a sine wave, another set of 3 nodes describes, say, a saw. You'd now just use simple linear interpolation to move the positions of the nodes from the sine wave representation to the saw representation, et voila, morphing. Or you move the center nodes of a square; boom, pwm. Etc. Etc.
All it needs is efficient assembler code...