Calculating effective area in Soccer

2 views (last 30 days)
I am currently trying to interpret how to code the attached algorithm (pictured).
Beginning information states "In order to create a polygon on the planar dimension, at least three points are necessary (i.e., triangle). Therefore, three players need to be considered to build triangles as the combinations of N players, in which N is the total number of players within a team."
The algorithm is then given.
I am wondering how this translates into MATLAB.

Accepted Answer

David Goodmanson
David Goodmanson on 20 Apr 2018
Edited: David Goodmanson on 20 Apr 2018

Hi William,

The algorithm draws a lot of triangles with players at the vertices. I appears that the final result for P is the polygon enclosed by the red boundary in the code below (the convex hull). After that, what the last line is doing is not so clear. Are you just looking for the area inside the boundary? If it's no more complicated than that, then the following code should get it done.

Let the players be at locations (x,y) and let vx be the vector of x coordinates and vy be the vector of corresponding y coordinates. Then

% make up some data
vx = 100*rand(1,11);
vy = 50*rand(1,11);
ind = convhull(vx,vy)             % indices of players on the boundary
plot(vx,vy,'o',vx(ind),vy(ind));
xlim([0 100]);
ylim([0 50]);
A = polyarea(vx(ind),vy(ind))
  2 Comments
William Sheehan
William Sheehan on 21 Apr 2018
Thanks David, that looks awesome!
Is there away to formulate the code in a way that measures the change in area over time, i.e. on a second to second basis over a 30 second window?
I would like to apply this code to different 30 second periods throughout the game using (x,y) coordinate data.
David Goodmanson
David Goodmanson on 21 Apr 2018
Hi William,
that would not be hard to do, you just need vx and vy for each of those one-second intervals. How would you be storing/accessing the vx and vy data?

Sign in to comment.

More Answers (1)

William Sheehan
William Sheehan on 21 Apr 2018
Data is collected and exported to excel with a separate spreadsheet for each individual (as pictured). Only values that will be relevant will be the latitude (vx) and longitude (vy) columns. Is it best to create two new spreadsheets - one with all individuals vx values over time side by side and another separate one with all the vy values?
  8 Comments
William Sheehan
William Sheehan on 14 Aug 2018
Hi David,
This appears to work well! Instead of using the area from convhull and the conversion you provided, I am using areaint function with "earthradius" which provides the area in metres squared. Both the results were very similar. Which would be more reliable ?
David Goodmanson
David Goodmanson on 14 Aug 2018
Hi William, probably areaint, since it is part of a Matlab toolbox. According to wikipedia, the earth's radius varies from 6353 km to 6384 km depending on location. For all I know, areaint has a lot of data and uses the radius appropriate to Sydney. earthradius gives 6371. I used 6370 so I would be interested to know how the answers compare if you changed the 6370 I used to 6371.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!