Most used math function and constants?

Hello, I would like to know which are the most used Math functions and constants according to your experiences and which ones you recommend to learn and use.

math (roblox.com)

1 Like

it’s depends. for magnitude most people use math.abs, so this thing turns number with minus at the start to plus (we don’t see this plus of course). i saw alot of calculations with math.pi, this is very useful constant number. i would name my list of others useful things:

  • math.floor
  • math.ceil
  • math.clamp
  • math.random
  • math.deg, rad
  • math.sin, cos, tan

i think thats the most useful math functions.

2 Likes

I use the most:

  • math.cos returns the cosine of the angle given in radians
  • math.acos returns the inverse cosine of the number
  • math.sin returns the sine of the angle given in radians
  • math.asin returns the inverse sine of the number
  • math.floor returns the largest integer smaller than or equal to x
  • math.ceil returns the smallest integer larger than or equal to x
  • math.abs returns the absolute value of the number (basically the distance between 0 and the number)
  • math.max given a & b numbers, it returns the greatest
  • math.min given a & b numbers, it returns the smallest
  • math.rad returns x, but in radians (i also use angle/180*3.1415926535898)
  • math.deg returns x, but in degrees (i also use angle/3.1415926535898*180)
  • math.pi returns pi
  • tau (math.pi*2) this isn’t a math function, but a constant that may be useful

I think they aren’t that hard to learn, and they are useful.

3 Likes

I actually just used math.cos/sine to rotate a 2D vector for my wall builder.

The post and code is here: Wall Builder | Smoothening Algorithm - #2 by MrNicNac

image

The red vector is the direction to the next blue square. Then, using math.cos/math.sine, I rotated the vector on the XZ plane 45 degrees (yellow vectors)

1 Like