直線斜率:
float SlopeBetweenPoints (float *p1, float *p2) //???浮點數組???
{
return (p2[1] - p1[1]) / (p1[0] - p2[0]);
}
判斷垂直:
// to determine the slope of the line perpendicular(垂直) to ourselves
float perpSlope (float slope) //slope - the slope of our line
{
return -1 / slope;
}
// to determine whether two lines are perpendicular
bool areperp (float slope1, float slope2)
{
if(slope1 * slope2 == -1)
return true;
return false;
}