Checking to see if 3 points are on the same line

前端 未结 5 1233
天涯浪人
天涯浪人 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 09:06

    Rule 1: In any linear 2d space, two points are always on the same line.

    Take 2 points and build an equation that represents a line through them. Then check if the third point is also on that line.

    Good luck.

提交回复
热议问题