So someone I knew wrote some code that I have adapted to processing to create a randomized slope based on what appears to be the first four terms of a randomized Fourier series (?). I've been writing a project where I want to know what the tangent line is at each point so that I can align a sprite correctly. Unfortunately, I haven't had too much success. Part of the problem is that I'm not sure if the derivative is correct, and the other is that I'm not entirely sure that I'm drawing the line correctly (regardless of whether the derivative is anywhere near what it should be.
Any pointers or assistance would be most appreciated. This is what I have so far:
final int w = 800;
final int h = 480;
double[] skyline;
PImage img;
int numOfDeriv = 800;
int derivModBy = 1; //Determines how many points will be checked