Trigonometry

From Legacy Roblox Wiki
Jump to navigationJump to search

Introduction

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

What is Trigonometry?

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

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 a^2 + b^2 = c^2. 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.

Example: a=3
b=4
c=?

a^2+b^2=c^2
3^2+4^2=c^2
9+16=c^2
25=c^2
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.

Why...?

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.
So, 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) = 3/5 = 0.6.
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.

Now, let's add up all three angles to see if we're right and see if we get 180 degrees.

and... A + B + C = 180 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, .1 do

y=100*math.sin(i)

p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(100*i, y+100, 0))
p.Size = Vector3.new(8,8,8)
p.Anchored = true
p.BottomSurface = "Smooth"
p.TopSurface = "Smooth"
p.Parent = game.Workspace
p.BrickColor = BrickColor.new(26)

end

See also

The wikipedia article on Trigonometry

A listing of mathematical functions