Checking to see if 3 points are on the same line

前端 未结 5 1234
天涯浪人
天涯浪人 2020-11-30 08:18

I want to know a piece of a code which can actually tell me if 3 points in a 2D space are on the same line or not. A pseudo-code is also sufficient but Python is better.

5条回答
  •  我在风中等你
    2020-11-30 08:57

    y - y0 = a(x-x0) (1) while a = (y1 - y0)/(x1 - x0) and A(x0, y0) B(x1, y1) C(x2, y2). See whether C statisfies (1). You just replace the appropriate values.

    Details

提交回复
热议问题