Jump to content
  • Advertisement
Sign in to follow this  
ironbox

COS()

This topic is 5122 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!