# COS()

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

## Recommended Posts

i making a thign for proj. motion but i can't get cos() to work. heres the code. In addtion to the cos() problem, im wanting to make an x,y graph. Can someone make a simple function to input x,y corrds and it will clear the screen and put a * or something at x,y. I know about goto(x,y), or something, but have never used it, i don't know what header file goto(x,y) is in either. #include <iostream> #include <stdlib.h> #include <cmath> using namespace std; ////////////////////////////////////// // Variables- // theta = angle // vo = original velocity // vox = original velocity along x // voy = original velocity along y // t = time // dx = displacement of x // dy = displacement of y // ax = acceleration along x // ay = acceleration along y // vfy = a velocity along y ////////////////////////////////////// double theta, vo, vox, voy, t=0, dx=0, dy=0, ax=0, ay=0; ////////////////////////////////////// // Function Prototypes ////////////////////////////////////// void GetValues(); void SetVelocities(); int main() { GetValues(); SetVelocities(); system("PAUSE"); return 0; } void GetValues() { do { cout << "What is the angle at which the projectile "; cout << "is launched? 0-90" << endl; cin >> theta; } while((theta > 90) || (theta < 0)); cout << "What is the velocity at which the "; cout << "projectile is launched? m/s" << endl; cin >> vo; } void SetVelocities() { cout << "theta = " << theta << endl; vox = vo*(cos(theta)); cout << "theta = " << theta << endl; cout << "vo = " << vo << endl; cout << "vox = " << vox << endl; }

##### Share on other sites
cos accepts radians as the argument. are you passing radians or degrees? from you code, it looks like degrees.

to convert from degrees to radians:

float radians = degrees * PI/180.0f;

-me

##### Share on other sites
thanks, ill try it

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

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633725
• Total Posts
3013568
×