Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How does math.sin(tick()) work?

Asked by 8 years ago

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?

0
What do you mean, 'how does it work'? Are you asking what math.sin does, or are you asking why someone would use math.sin(tick())? DigitalVeer 1473 — 8y
0
well, print(tick()) prints something like 1443811072.8355. print(math.sin(tick())) prints something that's -1 - 1. How is it converting a number that keeps getting bigger into a modulation that is between -1 and 1 johnnygadget 50 — 8y
0
Sine is a weird geometry/trig thing that i haven't learned yet. Tick is a number of seconds since some date. It's always increasing (every second). This makes it useful for keeping track of how long something took to happen. Perci1 4988 — 8y
0
Tick is the amount of seconds since the unix Epoch. shayner32 478 — 8y

2 answers

Log in to vote
2
Answered by 8 years ago

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

Ad
Log in to vote
1
Answered by 8 years ago

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).

0
cool I'll have to play with this johnnygadget 50 — 8y

Answer this question