We use cookies on this site to enhance your user experience

Jul 02 2018, 5:19 PM PST 2 min

Trigonometry is the mathematical study of right triangles, their angles and side lengths.

This tutorial is intended to explain the fundamentals of Trigonometry, the sine and cosine functions, and their use in Roblox.

Why right triangles?

All right triangles on a flat plane have ratios between their angles and sides. It doesn’t matter how big or small the triangle is. This means that, by having some limited information about the triangle, you can figure out the rest of the information about the triangle.

You may be familiar with the formula a2 + b2 = c2. This means that the square of the length of the adjacent side plus the square of the length of the opposite side equals the square of the length of the hypotenuse of a right triangle.


a = 3, b = 4, c = ?

a2 + b2 = c2
32 + 42 = c2
9 + 16 = c2
25 = c2 5 = c

As we can see, with limited information, it is possible to figure out the rest of the information about the triangle. This ratio applies to other, larger and smaller right triangles with sides that aren’t whole numbers.

But what about angles?

This is where functions such as sine and cosine come in. Roblox incorporates these as math.sin (x) and math.cos" (x). Sine is a ratio of the length of the opposite to the hypotenuse in a right triangle. Cosine is the ratio of the length of the adjacent to the hypotenuse. Tangent is the ratio of the opposite to the adjacent.


Because with these simple functions, you can actually find out the angles of your triangle.
Let’s go back to our triangle above.

  • We know that we have 3 angles… all together they must add up to 180 degrees.
  • We have an angle at point A (capital A) across from the “opposite” (small letter a).
  • We know that its sine value will be… (opposite/hypotenuse).

If you take the “Inverse sine” for 0.6, you will get the value in degrees for that angle: 36.89 degrees

We have another angle at point B.

  • Its Sine value is… 4/5… (opposite/hypotenuse) = 0.8
  • The inverse sine of 0.8 = 53.13 degrees

Finally, we know the value for our right angle, which is 90 degrees.
This is only the beginning of the amazing things you can do with trigonometry.

An example of this being used in Roblox

Both math.sin and math.cos functions have a distinctive wave shape. This simple script will show you the look of the sine wave.

for i = 1,40,0.1 do
	local y = 100*math.sin(i)
	local p = Instance.new("Part")
	p.CFrame = CFrame.new(100*i,y+100,0)
	p.Size = Vector3.new(8,8,8)
	p.Anchored = true
	p.BottomSurface = "Smooth"
	p.TopSurface = "Smooth"
	p.Parent = workspace
	p.BrickColor = BrickColor.new(26)

See also

  • coding
  • concept
  • lua