finowns
April 6th, 2008, 10:29 PM
I need help finding cos, sin, and tan of an angle. I cannot use the intrinsic function COS,SIN already in C++. Instead we have to use cos (x+y)= cos(x)cos(y)-sin(x)sin(y) and cos^2(x)+sin^2(x)= 1, to find the cos and sin of the angle.(I'm really confused on this)
This is what I got so far:
//Finds sin,cos,tan of angle and quadrant
#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
double angle, sin, cos, tan, quadrant, end;
cout << "Enter angle.\n";
cin >> angle;
while (angle > 360)
{
angle = angle - 360;
}
if (angle <= 90)
cout << "angle is in Quadrant 1\n";
else if ((angle <= 180) && (angle >= 91))
cout << "angle is in Quadrant 2\n";
else if ((angle <= 270) && (angle >= 181))
cout << "angle is in quadrant 3\n";
else if ((angle <= 360) && (angle >= 271))
cout << "angle is in quadrant 4\n";
Any help would be appreciated. Thanks!
Adding some more info (from assignment paper):
So if you know that cos(1) = 0.9998477, then by using cos^2(x)+sin^2(x)=1 you can get to sin^2(1). You need to decide if it is positive or negative, since 1 degree is in the first quadrant, then its sin must be positive, so it will be sin=sqrt(1-0.9998477^2).
From cos(1) and sin(1) you can get cos(1+1), from the first equation. Then you can get sin (2). You can repeat this until you get all the cos and sin for all the angles in 1 degree increment.
This is what I got so far:
//Finds sin,cos,tan of angle and quadrant
#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
double angle, sin, cos, tan, quadrant, end;
cout << "Enter angle.\n";
cin >> angle;
while (angle > 360)
{
angle = angle - 360;
}
if (angle <= 90)
cout << "angle is in Quadrant 1\n";
else if ((angle <= 180) && (angle >= 91))
cout << "angle is in Quadrant 2\n";
else if ((angle <= 270) && (angle >= 181))
cout << "angle is in quadrant 3\n";
else if ((angle <= 360) && (angle >= 271))
cout << "angle is in quadrant 4\n";
Any help would be appreciated. Thanks!
Adding some more info (from assignment paper):
So if you know that cos(1) = 0.9998477, then by using cos^2(x)+sin^2(x)=1 you can get to sin^2(1). You need to decide if it is positive or negative, since 1 degree is in the first quadrant, then its sin must be positive, so it will be sin=sqrt(1-0.9998477^2).
From cos(1) and sin(1) you can get cos(1+1), from the first equation. Then you can get sin (2). You can repeat this until you get all the cos and sin for all the angles in 1 degree increment.