數理應用 1.2 1.3 線

直線斜率:

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;

}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章