-
Slope to degrees
Does anyone know how to compute the azimuth in degrees from the given slope. If the two components (the numerator and the denominatory or x component and y component) are known. This is what I have but I am not sure that it is correct.
Code:
double ComputeAzimuth(double dbY, double dbX)
{
int iQuadrant = 0;
double slope;
slope = dbY/dbX;
if( dbX > 0 && dbY > 0)
{
iQuadrant = 1;
}
else if( dbX < 0 && dbY > 0)
{
iQuadrant = 2;
}
else if( dbX < 0 && dbY < 0)
{
iQuadrant = 3;
}
else if( dbX > 0 && dbY < 0)
{
iQuadrant = 4;
}
switch( iQuadrant )
{
case 1: return 90 - (atan(slope) * (180/PI));
case 2: return 270 - (atan(slope) * (180/PI));
case 3: return 270 - (atan(slope) * (180/PI));
case 4: return 90 - (atan(slope) * (180/PI));
}
return 0.0;
}
-
correction
By the way vertical and horizontal azimuths such as 0, 90, 180, 270 are treated as special cases so they don't need to be computed through this function.
-
if I understand your question properly, you wont to know how to calculate the inclination from the x axis of function.
m == slope
deg == Degree
so
inverse tan m = deg
tan deg = m
convert as need be
Hope this helps ;)
-
My understanding (different from wistlenm1) is that you want to calculate the bearing of a point {dbX, dbY} from the origin taking the positive y-axis as reference 0 degrees and measuring clockwise (like a compass bearing). If I am right in my understanding, then I reckon your code will give you the answer you want...