#### Archived

This topic is now archived and is closed to further replies.

# trigonometrie

This topic is 5793 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, i''ve heard there where a lot of things on trigonometrie that we can use in gaming but the problem is that i''m only in grade 8 and they don''t show me stuff like sinus, cosinus and tageant. so i would like to know them to appply it in a game. p.s. don''t tell me stuff like to do the sinus you so sin(the degree) i wan''t to know the formula to apply it. thanks

##### Share on other sites
I''m in 12th grade right now (in calc) and I want someone to show me an application of that stuff... lol... but anyway, I haven''t done a whole lot of programming but from what I understand, the trig functions are important for rotating things. I don''t really know enough about it to post, but I''ve definetly seen sin/cos used in rotation. I''m sure there are uses as well though.

I dunno about you, but in trig, I also learned about dot products, cross products, vectors, and matrices (though ask me to do them now and I couldn''t do them to save my life, lol). The reason I say that is because my trig class did have some calculus integrated into it, such as derivatives, so not all of the above topics have to do with trig, necessarily. All of the above though can be used for 3D transformations... I think. Especially matrices, which seem to be very important for 3D transformtions.

Okay, enough from me, since I don''t know a whole lot about the topic anyway, hehe. Hopefully ths gives you some insight into how you can apply what you learn and trig in programming. In hindsight, I wish I had paid more attention to certain topics

Peon

##### Share on other sites
Use Google, or look through the ''Articles & Ressources'' section. I''m sure that there is a tutorial on trigonometric functions somewhere.

Cédric

##### Share on other sites
First off, if you''re in eighth grade, you''re going to have a lot of problems with trig. Honestly. But it does have a lot of applications to game programming. Peon is right about using it to rotate points around other points in 3D. That''s a really complicated equation, and even I don''t understand it that well, so I can''t help you there. It can also be used to determine if one object is in another''s field of view. This application can be extended into only drawing what is necessary to the screen by only drawing what is visible to the player. The equation for this is 2*arctan((h/2)/d). Pretty simple concept- h is the screen height, d is the player''s distance to the screen. It can also be used to model phenomena that repeat over and over. For example, you can create an equation that models waves in water.

##### Share on other sites
I don''t know what grade 8 is exactly but I will give it a shot

Say you have a triangle:

|\
| \
4| \ 5
| \
| \
------ b

You now to sides of them, let''s say the longest one and the vertical one.

You want to know angle B. How to do that? Well you have the following equation:

sinus b = 4/5
b is then the inverse sinus of 4/5 = 53 degrees.

Well nice to know but how would that apply to game programming I hear you asking

Say you want to draw a circle.. how to know where to plot the points..

Now if you pick a pencil and some paper this will become somewhat clearer to you

Draw to axis(the x horizontal and the y vertical). Let them go from -1 to 1.

Draw a circle with a range of 1(sorry, don''t now the exact word for ''range'' in the english, it''s the distans from the center to the outer ring).

You have a circle that''s going trough (1,0) (0,1) (-1,0) (0,-1)

cos(0)=1
sin(0)=0

cos(90)=0
sin(90)=1

cos(180)=-1
sin(180)=0

cos(270)=0
sin(270)=-1

Does this sound familiar to you? That are exactly the points where the circle cuts trough the x/y axis. So if you give a sin function a value it will give you the y value and with a cos function the x value.

So if you make a loop where you put vertices on the values you get with cos(x),sin(x) you will draw a circle

There is only one more thing you need to know.. mostly games don''t work with degrees but with radians. Radians are measured in PI(yeah, that strange Greek symbol on your calculator )

PI = 3.14 and 360 degrees = 2PI. 1PI=180 degrees and so one.

So instead of letting x go from 0 to 360 degrees you could also lett it go from 0 to 2 PI.

If you exstent this part to 3d you will gain the ability to get the angle of rotation from 2 values. Draw a triangle and start calculating with sin/cos/tang

So, I hoped this little story helped you :D I''m pretty board tonight so if you need somewhat more explanation I could type something for you

And if one of the math gurus could check what I typed I will be gratefull :D

##### Share on other sites
is secondary 2 in a place called Quebec.
so i believe you come from there hearing from some stuff you told
me. By the way thanks . Cause i know that i will find someway to find the sin,cos,tang. Before i didn''t knew what was cos, sin but know i know.

##### Share on other sites
whooo, finishing up 8th grade and wanting to know trig.
Thats just plain cool. :D

scheermesje: I think you mean diameter.
D = 2r
r^2 = x^2 = y^2.
Anyway.
#1. Correct spelling is sine, cosine, and tangent.

Essentially, you have whats called a unit circle.

Its a circle with radius 1 and located at the origin.

Sine and cosine represent coordinates on that circle.

So you have a line coming off the origin interesecting the circle.

The cosine is the X value of that interesection, the sine is the Y value.

tan x = (cos x)/(sin x)

There are 2 different methods for representing size of an angle.

The "layman"''s one is degrees. 360 degrees are in a full circle.
90 is quarter turn, 180, half turn, etc.

The mathmetician''s one is the radian.
This is a PI based system.
So !

Remember the circumference is 2*PI*r.

So then, without going into the details of the derivation,
2PI is the number of radians in a circle.
So an angle of 2PI radians is congruent to a angle of 360 degrees.

Taking the sin, cos, or tan of congruent rads or degs will give the same answer, as you might guess.

sin and cos both vary from 1 to -1 everywhere.
They are nice that way.
Tan gets undefined at multiples of PI/2(90 deg).

Okay, you say, thats really nice, lets see some actual formulae to apply it.

The classic example is rotation.
I''m at a university lab computer and I don`t have the correct formulas in my head to tell you- I''ll get back to you on that.

Anything to do with angles probably is going to have to run through a trig function somewhere.

Another example is modulation between values(I''ve done this for something or another)
You need to get a value in a range.
Take the range amount, multiply it by sin or cos, using some algorithim for the input to the trig functions, and out pops a scaled value.

On a more theoretical note, trig funcs are what''s called trancedental functions.
That means you can''t quite do what you can with straight algebra functions like ax^2 + bx + c = 0.

I recommend getting a parent to buy a introductory trig book for you.

~V''lion

Bugle4d

##### Share on other sites
by the way if you would like to explain it more to me i would be greatfull if you could. cause or else i would of need to find the formula of sin,cos and tan. I already done it to find the surface of circle. I found it was diametre*diametre*pi/4. I talk to it to some one how know math and he told me it was good but the real formula invented by the egyptians(if i remember) was pi*r*r.

##### Share on other sites
If I remember correctly, you should learn trig in secondary 3 or 4, at most, so it''s not that far off, and anyway, you can do a lot of 2D games without ever needing a trig function.

Cédric

##### Share on other sites
quote:
Original post by alex8nder
I already done it to find the surface of circle. I found it was diametre*diametre*pi/4. I talk to it to some one how know math and he told me it was good but the real formula invented by the egyptians(if i remember) was pi*r*r.

But D^2*pi/4 = pi*r^2

The diameter is equal to 2r right? So D^2 = 2r*2r or 4r^2. So now, we have:

4r^2*pi/4

Simplify this and you would get your pi*r^2. Not sure if that is way over your head, but your diametre*diametre*pi/4 is equal to pi*r*r that your teacher told you, but yours just wasn't simplified.

Sin, Cos and Tan can also be expressed as the following:

Sin(Angle) = y/r
Cos(Angle) = x/r
Tan(Angle) = y/x

Think of an x and y grid. Y would be the height of your triangle and x would be the length of your triangle. Your r is the hypotenuse of the triangle, and is also the radius of a circle in which the triangle was inscribed inside.

Also remember that trig doesn't work for triangles that are not right angled. If you encounter a question where you have a triangle that is not a right angle triangle, you must apply the sin and cos laws which are:

Sine Law
(sin a)/a = (sin b)/b = (sin c)/c

Cosine Law (example would be assuming you're finding side C)
c^2 = a^2 + b^2 -2*a*b*cos c

[edited by - Apocalypse_Demon on January 19, 2003 12:08:17 AM]

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633679
• Total Posts
3013295
×