Drawing a oval shape to represent a race track given data

Question:

So I have data with 100s of dictionaries which include both X & Y values. These data represents the coords from the start of the race to the finish.

From this data, I have gotten the

MaxX, MaxY, MinX, MinY 

to figure the barrier of where the oval shape will need to be built. Based on position of one person in the race, the results can be shown below.

enter image description here

As you can see in the photo, all 4 (red) points using the variables above show the maximum part it can hit. The green dot represents the racer which I am trying to make a outter oval around and a inner oval within in.

Other data shows others racers which I have not included to keep it simple however the variables provides the MAX and MIN of all data.

The green dot must not go outside the outer oval or go in the inner oval.

The idea is to draw a race track. This is done using both python and matplotlib.

How the red dots are presented:


plt.grid()
plt.plot(minX,maxY,'ro')
plt.plot(maxX,minY,'ro')
plt.plot(minX,minY,'ro')
plt.plot(maxX,maxY,'ro')

How the race is being presented (the green dots):

for x in dicData:
    if x["I"][-2::] == "03":
        v = conversion(x["X"],x["Y"])
        plt.scatter(v[0], v[1], color = "green")
        plt.pause(0.01)

If statement checks for the data of a certain racer.

Data is converted to X and Y coords as data is from a GPS so lon and lan are given at first. This data is then drawn onto the graph.

Once I have managed to figure how to draw a race track, I will change to matplotlib animation. For now I have just done it in a loop.

I do not know the calculation nor what to do to create this type of shape. This is because it is going diagonal making it extremely hard for me.

EDIT:

IMG >>
IMG

I have now managed to create what I have wanted thanks to Brock Brown!!

Asked By: SocketLearner1302

||

Answers:

As far as the outside, you may be looking for a convex hull. For the inside, you could probably shrink the hull around the center until it doesn’t contain any points.

If the shape MUST be an oval, then you’re looking at an optimization problem. You could try an evolutionary algorithm maybe, using your conditions as a fitness function. The traits of the creatures should be the oval width and height, and the rotation of oval. The fitness function could be:
When calculating fitness for the outside oval – count the number of points inside the oval. If it’s equal to the total number of points, then for every point add 1/distance_from_the_oval to the score.
When calculating fitness for the inside oval – count the number of points outside the oval. If it’s equal to the total number of points, then add 1/distance_from_the_oval for each point to minimize the distance.

I might come back sometime tonight to take another look at this. Good luck!

Answered By: Brock Brown