Just a quick question today - does anyone know the header file in C that contains sine and cosine? I have a feeling that it's math.h, but I'm not sure.
Anyone care to enlighten me?
sine and cosine
- Magicfinger
- Staff
- Posts: 1078
- Joined: Tue Sep 30, 2003 10:38 am
- Location: here,there and everywhere
- Magicfinger
- Staff
- Posts: 1078
- Joined: Tue Sep 30, 2003 10:38 am
- Location: here,there and everywhere
particularly handy for 2d stuff is..
angle = asin(y/h)
angle = acos(x/h)
angle = atan(y/x)
etc.
Particularly handy as you'll often get in situations where u have the x,y coords or speeds of objects that you need to find the angle between.
Ya have to be careful with those tho, as there are special cases you need to take into account (like when the x in atan(y/x) is 0) and often you cannot get useful information from those equations without first knowing the relative positions of the objects involved.
angle = asin(y/h)
angle = acos(x/h)
angle = atan(y/x)
etc.
Particularly handy as you'll often get in situations where u have the x,y coords or speeds of objects that you need to find the angle between.
Ya have to be careful with those tho, as there are special cases you need to take into account (like when the x in atan(y/x) is 0) and often you cannot get useful information from those equations without first knowing the relative positions of the objects involved.