Ryuzoji
|
  |
| Joined: 21 Dec 2015 |
| Total Posts: 937 |
|
|
| 07 Jan 2016 09:22 PM |
http://wiki.roblox.com/index.php?title=Function_dump/Mathematical_functions
What's the uses for them?
I see scripts with math.sqrt, math.atan, etc.
I know a few of them, like math.ceil, math.floor, math.abs, etc. |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2016 09:27 PM |
| ceil rounds up if it has a decimal, floor rounds down, abs gets the absolute distance a number is form zero. |
|
|
| Report Abuse |
|
|
Ryuzoji
|
  |
| Joined: 21 Dec 2015 |
| Total Posts: 937 |
|
|
| 08 Jan 2016 07:33 AM |
Thanks, but I said I know those, lol.
What is math.sqrt, math.atan, etc. used for? |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2016 08:36 AM |
`math.sqrt` is the radicand function, basically. Returns the square root. `math.atan` is arc tangent. Idk what you'd use it for, but I've seen it in geometry uses. |
|
|
| Report Abuse |
|
|
nox7
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 27467 |
|
|
| 08 Jan 2016 08:51 AM |
It really just depends on what you need it for :|
atan, tanh, sinh, asin, sin, etc...
Those are functions for calculating trigonometric ratios. Solving right triangles or applying similar laws of triangles (law of cosines/sines). You'll need an issue with such to solve. |
|
|
| Report Abuse |
|
|
lupine
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 3561 |
|
|
| 08 Jan 2016 10:28 AM |
I mean, sin and cos are pretty important as they solve for the X and Y (respectively) vectors of a vector that doesn't lie on one axis. If you have a diagonal line and you know the angle it creates with the X axis, you can solve for both X and Y.
atan, acos, asin are all inverse functions of the base functions tan, cos, and sin respectively. Instead of taking an angle and spitting out a number, you put in a number (more often than not a fraction, such as 4/7) and it spits out an angle.
math.log is useful because then you can solve for x if x is an exponent, like 2^x = 8
max and min are my two favorite math functions. Super useful to find the max and min of a set of numbers (gasp, that's what they're used for?)
math.modf is neat. If I do local n,d = math.modf(3.1415) n = 3 d = 0.1415
math.noise is used in a lot of terrain generation algorithms. It uses Perlin noise (you may have also heard of Simplex noise). It's complex-ish, I wouldn't get into that if you don't need ot.
|
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 08 Jan 2016 11:02 AM |
math.atan2 is more commonly used for geometry
because: "It also handles correctly the case of x being zero." |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2016 11:08 AM |
Like lokkut stated, math.atan2 is more commonly used. For example, if you want to make a turret face towards a point, you would probably use math.atan2. But that doesn't mean that math.atan is useless. Probably, math.atan2 makes one or more calls to math.atan to do it's black magic.
I have personally used math.acos and math.asin to get angles from dot products of vectors, which is sometimes useful. |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2016 11:10 AM |
| Oh, and math.atan2 is not handy 'because it correctly handles the case of x being zero'. It's awesome because it deals with x AND y values, in all quadrants. |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2016 11:12 AM |
| Also also also, math.noise, math.random and math.randomseed are awesome for prodedural generation of all sorts of content. |
|
|
| Report Abuse |
|
|
Kamov
|
  |
| Joined: 07 Aug 2008 |
| Total Posts: 29015 |
|
|
| 08 Jan 2016 11:39 AM |
| For trigonometry obviously |
|
|
| Report Abuse |
|
|
Ryuzoji
|
  |
| Joined: 21 Dec 2015 |
| Total Posts: 937 |
|
| |
|