如何确定三点共线???
给出代码
30分

解决方案 »

  1.   

    三个点坐标x1,y1,x2,y2,x3,y3
    如果x1/y1 = x2/y2 = x3/y3 则三点共线!
      

  2.   

    var
       x1,y1,x2,y2,x3,y3 :float;
    begin
      if x1/y1 = x2/y2 = x3/y3  then ....//若不合你意则作差,看差的绝对值的范围!
      else ....end;
      

  3.   

    看来楼上几位数学太差了吧:
      if (Y1*Y2*Y3<>0) then
        if (x1/y1=x2/y2) and (x2/y2 = x3/y3) then
         //共线
      if Y1=0 and Y2=0 and Y3=0 then
         //共线 
    呵呵~~~~~~~~~
    X1/0不错就用鬼了!!
      

  4.   

    几位都弄错了,(0,1) (1,2) (2,3)这三点肯定在同一直线上,哪来的x1/y1 = x2/y2 = x3/y3.
      

  5.   

    我觉得这样也不对吧,给个反例:(0,1),(1,2),(2,3);
    if (y1<>y2) and (y3<>y2) then
      if (x2-x1)/(y2-y1)=(x3-x2)/(y3-y2) then //斜率相同
       //共线
    if (y1=y2) and (y2=y3) then         //水平时
       //共线
      

  6.   

    if x1=x2 then
      if x1=x3 then
        showmessage('在同一直线上')
      else
        showmessage('不在同一直线上')
    else
      if x2=x3 then
        showmessage('不在同一直线上')
      else
        if (y2-y1)/(x2-x1)=(y3-y2)/(x3-x2) then  //判断(x1,y1)与(x2,y2)
    //组成的直线的斜率是否与(x2,y2)与(x3,y3)组成的斜率相等
            showmessage('在同一直线上')
        else
            showmessage('不在同一直线上');