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

Can someone explain all of the math functions like I'm five years old?

Asked by 4 years ago

Alright, there are these math functions that I don't know anything about. Even the wiki doesn't give too much context on them.

Here are the functions I'm talking about:

math.acos
math.asin
math.atan
math.atan2
math.clamp
math.cos
math.cosh
math.exp
math.fmod
math.frexp
math.ldexp
math.log 
math.log10 
math.modf 
math.noise 
math.randomseed 
math.sign 
math.sin 
math.sinh 
math.tan 
math.tanh 
0
wow r u actually 5 years old? Because if u are I'm impressed that you are learning how to script at such a young age StarzSketchez 31 — 4y

2 answers

Log in to vote
4
Answered by
LazokkYT 117
4 years ago

I recommend you watch TheDevKing's video.

https://www.youtube.com/watch?v=seDPjYY4Gsw

Ad
Log in to vote
0
Answered by 4 years ago

Hi aHumanWhoExists68!

math.acos(x): Returns the arc cosine of x.

math.atan(x): Returns the arc tangine of x.

math.atan2(y, x): Arc tangent of two numbers. ATAN2(y,x) returns the arc tangent of the two numbers x and y. It is similar to calculating the arc tangent of y / x, except that the signs of both arguments are used to determine the quadrant of the result. The result is an angle expressed in radians.

math.clamp(x, y, z): Returns x, making sure that it is higher than y and lower than z. If x is lower than y, x will be equal to y. Similarly, if x is higher than z, x will be equal to z. (if i am correct)

math.cos(x): Returns the cosine of x.

math.cosh(x): Returns the hyperbolic cosine of x.

math.exp(x): Returns e^x.

math.fmod(x, y): Returns the remainder of x/y.

math.frexp(x): Returns m and e such that x = m*2^e, e is an integer and the absolute value of m is in the range [0.5, 1) (or zero when x is zero).

math.ldexp(x, e): Returns m*2^e (e should be an integer).

math.log(x, y): Returns the logarithm of x using y, or the mathematical constant e if no base is provided (natural logarithm).

math.log10(x): Returns the base 10 logarithm of x.

math.modf(x): Returns two numbers, the integral part of x and the fractional part of x.

math.noise(x, y, z): Returns a perlin noise value between -1 and 1. If you leave arguments out, they will be interpreted as zero, so math.noise(1.158) is equivalent to math.noise(1.158, 0, 0) and math.noise(1.158, 5.723) is equivalent to math.noise(1.158, 5.723, 0).

The function uses a perlin noise algorithm to assign fixed values to coordinates. For example, math.noise(1.158, 5.723) will always return 0.48397532105446 and math.noise(1.158, 6) will always return 0.15315161645412.

If x, y and z are all integers, the return value will be 0. For fractional values of x, y and z, the return value will gradually fluctuate between -0.5 and 0.5. For coordinates that are close to each other, the return values will also be close to each other.

math.randomseed(x): Sets x as the seed for the pseudo-random generator: equal seeds produce equal sequences of numbers.

math.sign(x): Returns -1 if x < 0, 0 if x == 0, or 1 if x > 0.

math.sin(x): Returns the sine of x.

math.sinh(x): Returns the hyperbolic sine of x.

math.tan(x): Returns the tangine of x.

math.tanh(x): Returns the hyperbolic tangine of x.

Some of these may be quite difficult to understand! I honestly have no idea how you would use these in a game, but those are the definitions.

I got most of my definitions here.

Sincerely, LennyPlayzYT

Answer this question