Home   Help Search Login Register  

Author Topic: sin, cos, tan, and all the other math stuff  (Read 733 times)

0 Members and 1 Guest are viewing this topic.

Merc

  • Guest
sin, cos, tan, and all the other math stuff
« on: 30 Apr 2005, 21:28:42 »
Can someone please explain to me how to use sin and cos and all the other stuff that are used to trianglulate stuff (please use small words if possible  ;D ). Or could someone point me in the direction of a tutorial that explains it. I used to know how but i forgot  :-\

bdfy1

  • Guest
Re:sin, cos, tan, and all the other math stuff
« Reply #1 on: 30 Apr 2005, 21:36:08 »
Any school math textbook will help you... And of course there are plenty of online tutes ( I know only russian ones thus I can't give you a link :()

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:sin, cos, tan, and all the other math stuff
« Reply #2 on: 30 Apr 2005, 21:44:53 »
One thing you need to remember is that:

x values increase from west to east
y values increase from south to north
and angles are measured clockwise from north.

Your next stop should be a text book.  Saying tell me about sine cosine etc. is like saying tell me about life, the universe and everything.  There is such a lot of it, even if the answer is 42.  I suggest the best thing is if you have something specific you want to do then try it with a text book and if that doesn't work come back and ask specificaly about your problem.

In the meantime you might find the following helpful:

==================== Formulae ===========================
To convert a relative position into an set of x,y coordinates
(for camera positioning)

if:
x1,y1 are the coordinates of the object
theta is the direction of the object
a,b are the relative position parameters

then
X coordinate = x1 + b*sin(theta) + a*cos(theta)
y coordinate = y1 + b*cos(theta) - a*sin(theta)

__________________________________________________________________________
To find the coordinates of a point in front of or to the side of an object
(these are sub-sets of the formula above)

if:
x1,y1 are the coordinates of the object
theta is the direction of the object
d is the distance of the point from the object

then:
For a point in front of the object
X coordinate = x1 + d*sin(theta)
y coordinate = y1 + d*cos(theta)

(for a point behind use -d or theta + 180


For a point to the right of the object
X coordinate = x1 + d*cos(theta)
y coordinate = y1 - d*sin(theta)

(for a point to the left use -d or theta + 180)

__________________________________________________________________________
To rotate a point about another point.  
This is useful if you select a random point in
a rectangular area, but you want the rectangle to be at an angle, not just north-south, east-west.

if:
x1,y1 are the coordinates for the point about which the rotation takes place
x2,y2 are the coordinates of the original location of the point to be rotated
theta is the angle of rotation

The coordinates of the rotated point are:
x = x1 + (x2-x1)*Cos(theta) - (y2-y1)*Sin(theta)
y = y1 + (y2-y1)*Cos(theta) + (x2-x1)*Sin(theta)



__________________________________________________________________________
To find the direction of unit 2 from unit 1

Direction =

(x2 - x1) atan2 (y2 - y1)

« Last Edit: 30 Apr 2005, 21:47:39 by THobson »

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:sin, cos, tan, and all the other math stuff
« Reply #3 on: 30 Apr 2005, 21:59:36 »
 ;D  I just knew THobson would find this one first.

Now look......you started him off on trigonometry again.
 ::) ::)



Planck
I know a little about a lot, and a lot about a little.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:sin, cos, tan, and all the other math stuff
« Reply #4 on: 30 Apr 2005, 22:06:45 »
We all need our own little niche. ;D
« Last Edit: 30 Apr 2005, 22:06:52 by THobson »

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:sin, cos, tan, and all the other math stuff
« Reply #5 on: 01 May 2005, 03:33:47 »
lol

Crassus

  • Guest
Re:sin, cos, tan, and all the other math stuff
« Reply #6 on: 01 May 2005, 15:44:48 »
Merc, toadlife has a tut specifically for OFP. :)

http://ofp.toadlife.net/tutorials.php

Scroll down, it's second one in list.
« Last Edit: 01 May 2005, 15:45:34 by Crassus »

Merc

  • Guest
Re:sin, cos, tan, and all the other math stuff
« Reply #7 on: 02 May 2005, 01:17:01 »
thanks everyone for the help.

@crassus

I am printing out toadlife's tutorial now and I'm going to read it right after it's done printing.

Crassus

  • Guest
Re:sin, cos, tan, and all the other math stuff
« Reply #8 on: 02 May 2005, 01:52:26 »
Jeepers, I didn't bother to check the integrity of the links themselves to the tutorials. Apparently there's some sort of bandwidth limitation, or something.

Were you able to d/l the tut?

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:sin, cos, tan, and all the other math stuff
« Reply #9 on: 02 May 2005, 19:11:13 »
Quote
... all the other stuff that are used to trianglulate stuff...
Wait, do you actually want to triangulate a position, from two other positions and directions? As in: I can see a mountain at 6 o'clock from grid A6, and I can see the same mountain at 4 o'clock from grid B5, so I want to triangulate the mountains position? Or did you just want to learn more about trigonometry?
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Bluelikeu

  • Guest
Re:sin, cos, tan, and all the other math stuff
« Reply #10 on: 02 May 2005, 20:49:46 »
Here are some of the basic trigonometric rules and theorems that I believe aren't really explained in Toadlife's tutorial.

In a right triangle with acute angle "theta"
Edit: Was going to put some sort of diagram, but that doesn't come out right in the forum.

                     
the sine of "theta" = length of leg opposite "theta"
                                 ________________________
                                 length of hypotenuse

the cosine of "theta" = length of leg adjacent to "theta"
                                     __________________________
                                     length of hypotenuse

the tangent of "theta" = length of leg opposite "theta"
                                       ________________________
                                        length of leg adjacent to "theta"

Note: The adjacent leg to "theta" is never the hypotenuse of the right triangle.

These formulas allow you to find all of the measurements of a right triangle.

If the "theta" is not known, you will need to use the inverses of the trigonometric functions. I'm not sure if OFP has this as a scripting command, but what the heck.

-1 will be used to symbolize the inverse function.

"theta" = sin-1(length opp. leg/ length hypot.)

"theta" = cos-1(length adj. leg/ length hypot.)

"theta" = tan-1(length opp. leg/ length adj. leg)


These commands should help you find the measurement of "theta"

Remember these theorems too.

Complements Theorem:

For all "theta" between 0 degrees and 90 degrees,
sin "theta" = cos (90 degrees - "theta")
cos "theta" = sin (90 degrees - "theta")

Pythagorean Identity Theorem:

For all "theta" between 0 degrees and 90 degrees,
(cos "theta")^2 + (sin "theta")^2 = 1

Tangent Theorem:

For all "theta" between 0 degrees and 90 degrees,
tan "theta" = sin "theta"
                      ________
                      cos "theta"

Hope this helped someone  :)
If you don't understand these formulas, just ask. ???

Thanks,
Bluelikeu
« Last Edit: 02 May 2005, 20:50:26 by Bluelikeu »

Merc

  • Guest
Re:sin, cos, tan, and all the other math stuff
« Reply #11 on: 05 May 2005, 23:15:52 »
@everyone
Thanks for all the help. Some of this stuff blew my mind, but now I get it. I am going to incorperate it into a script I am going to make this week hopefully.

@Crassus
I was able to download the tut and it helped a lot.