I know how to use it for modulating things, but I don't know HOW it works. I know what tick() is and I know what sines are, but can someone please explain how this works?
Your question is more of a trigonometry question. You can take a look at links to find out what functions things are, such as sin, cos, and tan.
They are highly important functions that basically set the base for all trigonometry. They coordinate with how angles of triangles function with most of time, circles.
I won't offer my explanation as to what is going on as I feel you should get a more formal and worked-out description from some other resources, such as:
Graphing Trig Functions:http://www.purplemath.com/modules/grphtrig.htm
Video Demonstration:https://www.khanacademy.org/math/trigonometry/trig-function-graphs/trig_graphs_tutorial/v/we-amplitude-and-period
Video Explanation: https://www.khanacademy.org/math/trigonometry/basic-trigonometry/cc-trig-ratios-similarity/v/similarity-to-define-sine-cosine-and-tangent
You can transform a large number into a small number by using the modulo operator %
. The following isn't how math.sin works, but it does transform any number to one in the range -1 to 1:
function Transform(n) return math.floor(n) % 3 - 1 end
math.sin is a similar idea (though significantly more complicated).