Project 6: Optimum Point along Path

Intro Problem: Suppose 4 friends want to meet at a point on a highway.  They want to find the point that would minimize the sum of the distances to all four points.


Coordinates for Friend 1: (-8.60993190199354, -3.414455557956355)

Coordinates for Friend 2: (-6.674243369468695, 9.601560870507857)

Coordinates for Friend 3: (0.34778911636656673, -6.511220166068994)

Coordinates for Friend 4: (5.741249040259312, 8.849265766978156)

Highway Equation: Y = -2.6289445201081163X + 6.220251582856811)

Desired Point = (0.7899999999998316, 4.143385411971842)

Project 6: Variables 'x1', 'y1', 'x2', 'y2', 'x3', 'y3', 'x4', 'y4', 'm', and 'b' have been initialized.  There is also a working method called sumDistances.

xi, yi are the coordinates for each point

m is the slope of the line that the desired point is on (-2.6289 for the example above)

b is the y-intercept of the line that the desired point is on (6.22025 for the example above)

sumDistances(x1,y1,x2,y2,x3,y3,x4,y4,p,q) returns the sum of the distances from each of the four points to the point (p,q)

Note: This logic was accomplished in task 5

Task: Appropriately initialize the values of 'x', 'y', and 'dist' which represents the point on the line that minimizes the sum of the distance between the four points and the total distance.

Note: You can assume that the x and y coordinates for the point will be in the range [-10, 10]

**If your code works for 5 test cases in a row, you can enter your e-mail address.