Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

May I have some examples of when to use math.cos, math.cosh, math.sin, math.sign, etc?

So, I see a lot of the math formulas in many scripts and I basically try to understand what it is and how it works but I simply can't As a tiny little 14 year old, I won't be able to understand some of it but... Hopefully you guys will be able to explain it.. I'd like to know how the tangent can be solved, how all these math equations come in handy in basic scripts.. And Could I also have some examples??

I only know tiny math like this:

math.floor()
math.rad()
math.ceil()
math.exp()
math.random()
math.Pow()

Also another question... Why do we need math.pow when math.exp is already there..?

Someone in discord server told me that using some math functions it can help with animating.. Although, why do we need it when we can animate an object using the roblox given animation plugin...?

If you guys have any answer, i'd like you guys to share it with me, Thank you

6 comments

0

FRUIT

0

AYYYYY ^

0

y u no eat

0

I ate dude, so good

0

A good way to learn basic trig stuff is to learn the unit circle - that's how it's taught in modern curriculum at least (alongside graphs). sin(x) = point y coord, cos(x) = point x coord, tan(x) = sin(x)/cos(x). It's just more algebra rules, but it's good stuff to know.

0

Here is something open-sourced I wrote last week that uses sin and cosine to visualize basic unit circles. https://twitter.com/TweetEquinox/status/1069787729062477824

1 answer

✓ Accepted answer

So some answers:

math.exp(x) returns e^x e is approximately 2.71828182846, but it's infinite like pi.

math.pow(x,y) returns x^y

math.rad(x) converts an angle in degrees to radians

math.random(start,end) is a pseudo random number generator which can be used for all kinds of things, like dance floors.

math.ceil(x) rounds up to the nearest whole number. math.floor(x) rounds down to the nearest whole number.

Cosine and Sine are used parametrically (as in each function goes to a variable) On an X/Y plane this would look like (cos(radian),sin(radian)) and would draw a circle with radius 1 and the origin.

This can be useful, but also knowing that cosine/sine looks like a wave can help as when you are animating things like waves you can trace a decent wave with these functions.

In addition the earlier math classes talk about lines, a lot of the functions you mentioned are useful because they let us create smoother curves than lines. The roblox animation editor can't handle every use case, and for some things it's easier to just math it yourself! In addition I'm sure you've noticed things like triangular terrain in some games, that's all built using trigonometric functions, as in sine, cosine, tangent, arcsin, arccos, arctan, etc.

There is a lot more behind these concepts and many of the functions have really deep and interesting uses outside of roblox.

If you have any more precise questions I'd love to take a moment to answer them.

7 comments

0

Wait so, when using cosine and sine, can't you just use slopes instead?? to make possibly better curves, y = mx+b

0

y = mx+b will only return a line. You can, through parametric equations with sine and cosine determine the equation of a tangent line. As an example (3cos(t),4sin(t)) on 0 to 2pi would create an oval. knowing that X = 3cos(t) X' = -3sin(t) and Y = 4sin(t) Y' = 4cos(t), using that we know that our m at any point would be m = Y'/X' for some angle t

0

If you want you should try this in a graphing calculator like Desmos! Pasting (3cos(t),4sin(t)) into the text box will draw the oval for you I'm talking about.

0

Oh so basically the functions I am learning in math class creates semicircles! Trignometry will create full circles with ovals and all?

0

Trig is all about triangles and how they relate to circles. You will learn a lot about solving for angles of triangles and side lengths. Towards the end you get into more of the unit circle stuff and how the triangles you've been learning about apply to other shapes, and how we can represent almost any curve as a series of triangles.

0

As an additional note, calculus is all about the math of infinity. Like, what happens to some function when we put infinity in for x? Or what happens if we take a look at an infinitely small portion of a function? How do we calculate the area under a curve: traditional answer is infinite rectangles.

0

Alright thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.