# Need help with understanding Math.fSin()

Updated on April 13, 2017 in
11 on April 13, 2017

Hey guys so I don’t get this method the sin. I guess its part of trigonometry I was doing the basics a bit but still don’t get it. Unity guide says: “Returns the sine of angle `f` in radians.” I can’t find on google what it means by sine can’t find a simple description. then not sure what it means by angle

transform.position = _startPosition + new Vector2(0, Mathf.Sin(Time.time * 5));
this code here makes the object move up and down but I don’t get how.

• Liked by
on April 13, 2017

To understand basic time functions like sine, cosine and tangent you should learn some basic trigonometry.

Look at how the sine function looks:

It goes up and down, that’s why the object is going up and down aswell.

Here are some videos on trigonometry:

Wise
on April 13, 2017

Ah ok thx.

• Liked by
on April 13, 2017

If you type in google search “sin(x)” it will show you a graph of sin(x). Sin, cos and tan are periodical functions that will go on and on with the same frequency. These functions use degree or radian input, depending on the function type that is used.

To get a better understanding about the radian part you can look at this:

A circle with a radius of 1 exists of 2pi radians (in other words 360 degree = 2pi). Both methods (degrees and radians) will give the same result when used in your calculations, only the function that you use will require 1 method all the time.

To understand the output of the sin and cos can be visualised with the following image:

When a vector with length 1 is rotating counter clockwise around the origin (0,0) the function cos(x), where x is the angle or radians, will give the X value of the angle/radian. The sin(x) function, where x is also the same angle or radian for the cos(x) function, will give the Y value of the same angle/radian. When the angle starts at 0 degree or 0 radians the vector will be pointing to the right. At this point the cosine function will output 1, because cos(0) = 1, and the sin function will output 0, because sin(0)=0. This can be checked in the previous picture (the blue vector will be at his maximum length and the green vector will not be visible at all so the length will be 0).

For a better understanding take a look at this gif animation about the sin, cos and tan function:

I hope this will give a better understanding about the sin and cos functions. If you want to get a closer look at the functions check the wiki

Devoted
on April 13, 2017

I think this is too much information condensed.

Wise
on April 13, 2017

Ah ok thanks man.

on April 13, 2017

Maybe you are right, but with some images and some basic information it is easier to understand. Your video explains the same information but is maybe easier to follow.

Edit: if you need to know how a function behaves, you can always enter it on google search and you will get a graph of it

Wise
on April 13, 2017

I watched that video thanks alot for it leon I see how it works sorta. The Time.time makes it moves if we just put a number in mathf.Sin(1); would never change.

Devoted
on April 13, 2017

Watch his other videos, he teaches some basic math for game development.

Wise
on April 13, 2017

Will do thanks alot.

• Liked by