I have list of vertices i.e List<Point>
, which contains following points for square:
(0,0),
(1,0),
(2,0),
(3,0),
(4,0),
(4,1),
(4,2),
(4,3),
(4,4),
(3,4),
(2,4),
(1,4),
(0,4),
(0,3),
(0,2),
(0,1),
(0,0)
To draw a square I just need four points (0,0), (0,4), (4,4), (4,0), how do I remove redundant (which makes straight line) points from list?
It is not always square, basically I want to reduced the number of points if they form straight line. For example (0,0), (0,1), (0,2), (0,3), (0,4) makes straight line instead of drawing all four points it would be quick to draw a line from points (0,0), (0,4).