What functions model this relationship?

44 Views Asked by At

I'm currently working a bit on an AI, and in order for it to function, it must be able to quickly predict where a point will be in space, given any distance. The movement of this point may be modeled as a linear graph 1 up until it reaches a maximum y value, at which point the movement begins to decrease with the slope -1 until the minimum y value.

The equation for the upward cycle of the function is $y=min+x-?$, but when the function is on a downward cycle, it becomes $y=max-x+?$. The $?$ in the equation represents a value which basically cancels out all growth in $x$ beyond the $min$ and $max$ respectively. For some reason, I strongly suspect that differential calculus is the means by which this can be solved, but I am currently only on a pre-calculus level of mathematics.

What I need is a function that is periodic and bounces between the min and max like a sine wave (or a periodic absolute value graph), but which has no curve. Does there exist any such function? If not, how may I go about finding an equation for this relationship?

1

There are 1 best solutions below

2
On BEST ANSWER

You either want http://en.wikipedia.org/wiki/Square_wave http://en.wikipedia.org/wiki/Sawtooth_wave or http://en.wikipedia.org/wiki/Triangle_wave. I don't think that they are expressible as "equations" in the way you're thinking, though they are certainly well defined functions. I would also guess that most programming languages would allow you to make such a function quite easily.