Created
May 1, 2012 18:34
-
-
Save kdmkdmkdm/2570310 to your computer and use it in GitHub Desktop.
Arc Tangent 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // giArcTangent2.cpp : Defines the entry point for the console application. | |
| // | |
| #include "stdafx.h" | |
| #include <iostream> | |
| #include <cmath> | |
| using namespace std; | |
| float MyArcTangent(float y, float x); | |
| int main() | |
| { | |
| cout << "MyArcTangent( 4, 2) = " << MyArcTangent( 4, 2) << endl; | |
| cout << "MyArcTangent( 5, -1) = " << MyArcTangent( 5, -1) << endl; | |
| cout << "MyArcTangent( -4, -6) = " << MyArcTangent( -4, -6) << endl; | |
| cout << "MyArcTangent( -6, 4) = " << MyArcTangent( -6, 4) << endl; | |
| } | |
| float MyArcTangent(float y, float x) | |
| { | |
| if(x >= 0) | |
| { | |
| float PI = 3.14; | |
| float answer = atanf(y/x); | |
| answer = (answer * 180) / PI; | |
| return answer; | |
| } | |
| else | |
| { | |
| float PI = 3.14; | |
| float answer = atanf(y/x); | |
| answer = ((answer * 180) / PI) + 180; | |
| return answer; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment