Reference no: EM133285061
Create this function
public static Triangle[] makeFakePoly(Point[] points)
The purpose of the makeFakePoly is to create arrays of triangles that can be used to draw more complicated polygons. The function takes an array of points. You can assume this array has at least 3 points in it. The function should return an array of triangles. Important - there are MANY ways to do this which would work in general. Our tests, however, are designed to look for one specific solution approach, which is outlined here. If you want to pass tests you will have to be careful to follow this pseudocode
Question 1. Create an array for outputting triangles. Ultimately this will need to be the same length as the input point array.
Question 2. Compute the "center point"
Question 3. for each array index i create a new triangle using p1 = points[i], p2 = points[i+1], p3 = center (For the final position, p1 = points[N - 1], p2 = points[0], p3 = center)
Question 4. return the new array
So if we gave the function the points [(1, 1),(1, 2),(2, 2),(2, 1)] it should return the 4 triangles (in this order): (1, 1) - -(1, 2) - -(1.5, 1.5) (1, 2) - -(2, 2) - -(1.5, 1.5) (2, 2) - -(2, 1) - -(1.5, 1.5) (2, 1) - -(1, 1) - -(1.5, 1.5)