SlopeFromAngle
short theAngle ; in degrees; ranging from -180 to +180
returns the line slope (dh/dv) as a 32-bit Fixed Given the angle of a line, this calculates the slope of that line. The slope is the
dh/dv ratio-the horizontal change divided by the vertical change-between any
two points on the line.
theAngle is an angle expressed in circular degrees (as opposed to the "angles
used in arc drawing). This parameter is treated MOD 180, with a
range of -180 to +180; positive values are clockwise from vertical
and negative values are counterclockwise.
Returns: a 4-byte Fixed value. It's the dh/dv ratio of points on theAngle that can be used in mathematical calculations; e.g., to extrapolate
additional points on a line.
Notes: The following example uses slope calculations to draws a line extending
from (100,100) at a 17° angle until it reaches row 50:
Example
#include <ToolUtils.h>
#define INT2FIX(i) ((long) i << 16 ) /* short to Fixed conversion macro */
short dh, dv;
startPt.h=100; startPt.v=100; /* one end point */ endPt.v = 50; Ô/* vertical coordinate of other end */
/* -------- calculate dv and dh; the vertical and horizontal distance */
dv = startPt.v - endPt.v; /* vertical is easy */ MoveTo( startPt.h, startPt.v ); /* move to start point */ Line( dh,dv ); Ô/* draw calculated distance */