Need help with understanding Math.fSin()

Updated on April 13, 2017 in [A] C# .Net
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
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
Reply
1 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:
https://www.youtube.com/watch?v=-dGi2Ffdiuk

Wise
on April 13, 2017

Ah ok thx.

Show more replies
  • Liked by
Reply
Cancel
6 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:

Link: https://upload.wikimedia.org/wikipedia/commons/4/4e/Circle_radians.gif

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:

Link: https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/Sinus_und_Kosinus_am_Einheitskreis_1.svg/418px-Sinus_und_Kosinus_am_Einheitskreis_1.svg.png

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:
Link: https://giphy.com/gifs/sin-cos-tan-129q8NTGIWhO2A 

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

Link: https://en.wikipedia.org/wiki/Trigonometry

Devoted
on April 13, 2017

I think this is too much information condensed.

Wise
on April 13, 2017

Ah ok thanks man.

Helpful
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

https://www.google.nl/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=sin(x)

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.

Show more replies
  • Liked by
Reply
Cancel
1 on April 13, 2017

do a search for Sebastian league on YouTube he did a vid on this today

Devoted
on April 13, 2017

I posted him the link.

Show more replies
  • Liked by
Reply
Cancel