------------------------------- Points inside triangle ------------------------------- Write a function that counts how many of a set of points are inside a given triangle. The location of the corners of the triangle is given by two vectors x = [x1 x2 x3] and y = [y1 y2 y3]. The set of N points is given by a 2xN matrix where each column specifies the (x,y) coordinates of the point. The x-coordinates are in the first ro and the y-coordinates are in the second row. + + + + + (x1,y1) o---------------o (x2,y2) \ + + / \ / \ + + / + \ / \ / + + \ + / \ / + o (x3,y3) Syntax: inside = triangle(x,y,points) ----------------------------- where "x" and "y" are the coordinates of the triangle corners, "points" is the 2xN matrix specifying the set of points, "inside" is the number of points that are insdide the triangle. Points "exactly" on the edges of the triangle count as inside the triangle. Basic functionality: >> x = [1 2 3]; >> y = [3 1 2]; >> points = [1.3 1.4 1.8 2.2 2.4 2.6 2.7 2.0; 2.8 1.4 2.9 1.7 1.6 2.1 2.8 2.0]; >> inside = triangle(x,y,points) inside = 5 -------------------------------