Sign in to follow this  

COS()

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this