Need help with trigonometry

everytime I’ve tried to learn how to use it in roblox and what it actually does, I just end up not understanding it, I just wanna know what it does and how to effectively use it in studio

1 Like

Trig is just math (the study of triangles). You can learn it in school or online. There’s a lot of content so there’s really no way to explain all of it.

Trigonometry is used to measure and calculate angles and distances between angles in geometry, basically, the study of triangles and angles.

The most popular use for trigonometry in development is creating smooth animations using sine waves.

A basic sine wave might look something like this:

We can use lerping(linear interpolation) to interpolate size, position e.t.c(mainly position) between this curve to make cool effects that have arches or bobbing effects.

You make a sine wave with:

math.sin(x)

This is just the most basic sine wave possible. This just returns the ratio to the opposite side of the hypotenuse in a right triangle. This is the main one you’re going to be using.

There’s a ton of tutorials on trigonometry. Im just too lazy to explain it here. Google some tutorials on it, you might find some useful information.

A big one is atan2. It’s a piecewise function that’s essentially a modified version of arctangent. You give it coordinates in 2D space and it spits out its angle relative to the origin. It’s useful anything that rotates.

image

image

It’s usually used to rotate objects or calculating positions based on angles.

Here’s an example on how it can be used to rotate an object or move it in a circular path.

local radius = 10
local angle = tick() 

local x = radius * math.cos(angle)
local y = radius * math.sin(angle)

part.CFrame = CFrame.new(x, y, 0) 

( The Post Was Deleted By The Author )

Trigonometry is a way to calculate things in a triangle according to it’s sides and angles.

I think the first part stands in understanding it for right-angle triangles. For this, there are 3 formulas, and some vocabulary, let’s go ahead:

Vocabulary:

We’ll chose H for the hypotenuse (the big side), A for the adjacent (the other side that touches the angle) and O for the opposite (the last one).

The Lua appealations:

Sine = math.sin
Cosine = math.cos
Tangent = math.tan

Sine inverse = math.asin
Cosine inverse = math.acos
Tangent inverse = math.atan

Now for the formulas:

Sin(a) = O / H (SOH to remember it)
Cos(a) = A / H (CAH to remember it)
Tan(a) = O / H (TOA to remember it)

SOH CAH TOA is the mnemotechnic thing. With those formulas, all you need to know the sides of a triangle is:

  • 1 angle
  • 1 right-angle
  • 1 side with a known size

OR:

  • 2 sides (you can use Pythagorean here but let’s say we don’t)
  • 1 right-angle

In the first case, identify which side is the one you know. Now look for a formula where there’s your angle and the side you know, and solve the equation.

Let’s say we know A which is 3 and the angle 35°. We’ll have to use CAH to find the hypotenuse which will give:

Cos(35) = 3 / H

Let’s say it’s 2 = 10 / 5. How do you get 5? 10 / 2. So you know what to do. 3 / Cos(35). In scripts this will look like this:

H = 3 / math.cos(35)

And boom! You now know your hypotenuse.

Now, second scenario. You know two sides, and you don’t want to use Pythagorean. Here, choose an angle, and find the good formula to get the angle. The final result won’t be the angle first, but you need to do the inverse of the sine/cosine/tangent depending on the formula.

This will give something like that (a is the angle, and we know O = 3 and H = 5):

a = math.asin(3 / 5)

And when you have the new angle, just do like before and you can find your sides! Tell me if something’s not clear.

1 Like