123456789101112131415161718192021222324252627282930313233343536
#include <cmath> #include <iostream> using namespace std; float Points_to_Degrees(float x1, float y1, float x2, float y2) { // find slope of inputted points, convert to degrees (via formula above) // put points through if statements, return variable dir to main float dir = 0.0f; float var_slope = ( (y2 - y1) / (x2 - x1) ) * 45; if (x2 > x1 && y2 > y1) dir = var_slope + 0; if (x2 < x1 && y2 > y1) dir = var_slope + 90; if (x2 < x1 && y2 < y1) dir = var_slope + 180; if (x2 > x1 && y2 < y1) dir = var_slope + 270; return dir; } int main() { float x1, y1, y2, x2; float Answer; Answer = Points_To_Degrees(x1, y1, x2, y2); }
Points_To_Degrees
Points_to_Degrees