The Mathematics of The Triangle Offense, Continued…

In a previous post, I showed how given random positions of 5 players on the court that they could “fill” the triangle. The main geometric constraint is that 5 players can form 3 triangles on the court, and that due to spacing requirements, these triangles are “optimal” if they are equilateral triangles.

Given that we now know how to fill the triangle, the question that this post tries to address is that how can players actually move within the triangle. The key is symmetry. Players must all move in a way such that the equilateral triangles remain invariant. Equilateral triangles have associated with them the D_{3} dihedral symmetry group. They are therefore invariant with respect to 120 degree rotations, 240 degree rotations, 0 degree rotations, and three reflections.

There are therefore six generators of this group:
\left( \begin{array}{cc} 1 & 0 \\ 0 & 1 \\ \end{array} \right), \left( \begin{array}{cc} -\frac{1}{2} & -\frac{\sqrt{3}}{2} \\ \frac{\sqrt{3}}{2} & -\frac{1}{2} \\ \end{array} \right),\left( \begin{array}{cc} -\frac{1}{2} & \frac{\sqrt{3}}{2} \\ -\frac{\sqrt{3}}{2} & -\frac{1}{2} \\ \end{array} \right), \left( \begin{array}{cc} \frac{1}{2} & \frac{\sqrt{3}}{2} \\ \frac{\sqrt{3}}{2} & -\frac{1}{2} \\ \end{array} \right),\left( \begin{array}{cc} -1 & 0 \\ 0 & 1 \\ \end{array} \right),\left( \begin{array}{cc} \frac{1}{2} & -\frac{\sqrt{3}}{2} \\ -\frac{\sqrt{3}}{2} & -\frac{1}{2} \\ \end{array} \right).

In fact, the Cayley graph for this group is as follows:


For now, I will discuss how players can move within the action of 120 degree rotations. As in the previous posting, let the (x,y)-coordinates of player i be represented by (x^{i}, y^{i}), where i = 1,2,3,4,5. Then, under a 120 degree rotation, the player’s coordinates get shifted according to:

\boxed{x^{i}_{t+1} = \frac{1}{2} \left(-x^{i}_{t} - \sqrt{3}y^{i}_{t}\right), \quad y^{i}_{t+1} = \frac{1}{2}\left(\sqrt{3}x^{i}_{t} - y^{i}_{t}\right)}

This is a discrete dynamical system. In fact, it can be solved explicitly. Let x^i_{0}, y^{i}_{0} represent the initial coordinates of player i. Then, one solves the above discrete system to obtain:

\boxed{x^i_t =\frac{1}{2} e^{\frac{1}{3} (-2) i \pi t} \left[\left(1+e^{\frac{4 i \pi t}{3}}\right) x^i_0+i \left(-1+e^{\frac{4 i \pi t}{3}}\right) y^i_0\right], \quad y^{i}_{t} =\frac{1}{2} e^{\frac{1}{3} (-2) i \pi t} \left[\left(1+e^{\frac{4 i \pi t}{3}}\right) y^i_0-i \left(-1+e^{\frac{4 i \pi t}{3}}\right) x^i_0\right]}

Now, we can simulate this to see actually how players move within the triangle offense, forming equilateral triangles in every sequence:


This is running in continuous time, that is, endlessly. In future postings, I will update this to include the other symmetries of the dihedral D_{3} group. However, the challenge is that this symmetry group is non-Abelian, so it will be interesting to implement pairs of consecutive symmetry operations in a simulation that would still result in invariant equilateral triangles.

Hopefully, this post also shows why teams cannot really run “parts” of the triangle, as one player’s movement necessarily effects everyone else’s. This is something that Charley Rosen also mentioned in an article of his own.  

The Mathematics of “Filling the Triangle”

I’ve been fascinated by the triangle offense for a long time. I think it is a beautiful way to play basketball, and the right way to play basketball, in the half-court, a “system-based” way to play. For those of you that are interested, I highly recommend Tex Winter’s classic book on the topic.

There is this brief video as well where Tex Winter explains how the triangle offense and a basketball are grounded in geometric principles:


I don’t think people recognize though how deep of a geometry problem this is actually. Looking at when the triangle is filled, as in the video above, we have the following situation:

The 3 triangles that form when one triangle is filled involving all 5 players. The letters a,b,c,d,e,f,g,h,i denote the angles within the triangles. We are assuming NBA court dimensions where the 1/2 court is 47′ long and the team bench area which roughly corresponds to the top of the three-point line is 28′ from the baseline.

The problem I wanted to study was given 5 players’ random positions on the court, could a series of equations be solved yielding (x,y) coordinates that would yield where players should “go” to fill the triangle? 

Using simple geometry, from the diagram above, we see that each player’s position in the triangle offense is governed by the following system of nonlinear equations:

\left(x_4-x_2\right) \left(x_4-x_5\right)+\left(y_4-y_2\right) \left(y_4-y_5\right)=\cos (a) \sqrt{\left(x_2-x_4\right){}^2+\left(y_2-y_4\right){}^2} \sqrt{\left(x_4-x_5\right){}^2+\left(y_4-y_5\right){}^2}

\left(x_4-x_2\right) \left(x_2-x_5\right)+\left(y_4-y_2\right) \left(y_2-y_5\right)=\cos (b) \sqrt{\left(x_2-x_4\right){}^2+\left(y_2-y_4\right){}^2} \sqrt{\left(x_2-x_5\right){}^2+\left(y_2-y_5\right){}^2}

\left(x_2-x_5\right) \left(x_4-x_5\right)+\left(y_2-y_5\right) \left(y_4-y_5\right)=\cos (c) \sqrt{\left(x_2-x_5\right){}^2+\left(y_2-y_5\right){}^2} \sqrt{\left(x_4-x_5\right){}^2+\left(y_4-y_5\right){}^2}

\left(x_2-x_1\right) \left(x_2-x_5\right)+\left(y_2-y_1\right) \left(y_2-y_5\right)=\cos (d) \sqrt{\left(x_1-x_2\right){}^2+\left(y_1-y_2\right){}^2} \sqrt{\left(x_2-x_5\right){}^2+\left(y_2-y_5\right){}^2}

\left(x_2-x_1\right) \left(x_1-x_5\right)+\left(y_2-y_1\right) \left(y_1-y_5\right)=\cos (e) \sqrt{\left(x_1-x_2\right){}^2+\left(y_1-y_2\right){}^2} \sqrt{\left(x_1-x_5\right){}^2+\left(y_1-y_5\right){}^2}

\left(x_1-x_5\right) \left(x_2-x_5\right)+\left(y_1-y_5\right) \left(y_2-y_5\right)=\cos (f) \sqrt{\left(x_1-x_5\right){}^2+\left(y_1-y_5\right){}^2} \sqrt{\left(x_2-x_5\right){}^2+\left(y_2-y_5\right){}^2}

\left(x_1-x_3\right) \left(x_1-x_5\right)+\left(y_1-y_3\right) \left(y_1-y_5\right)=\cos (h) \sqrt{\left(x_1-x_3\right){}^2+\left(y_1-y_3\right){}^2} \sqrt{\left(x_1-x_5\right){}^2+\left(y_1-y_5\right){}^2}

\left(x_1-x_3\right) \left(x_3-x_5\right)+\left(y_1-y_3\right) \left(y_3-y_5\right)=\cos (i) \sqrt{\left(x_1-x_3\right){}^2+\left(y_1-y_3\right){}^2} \sqrt{\left(x_3-x_5\right){}^2+\left(y_3-y_5\right){}^2}

\left(x_1-x_5\right) \left(x_3-x_5\right)+\left(y_1-y_5\right) \left(y_3-y_5\right)=\cos (g) \sqrt{\left(x_1-x_5\right){}^2+\left(y_1-y_5\right){}^2} \sqrt{\left(x_3-x_5\right){}^2+\left(y_3-y_5\right){}^2}

Further, the angles obviously must satisfy the following constraints:

a + b + c = \pi, \quad d + e + f = \pi, \quad g + h + i = \pi

Finally, we require that each player be about 15-20 feet apart in the triangle offense (because the offense is predicated on spacing), and thus have some additional constraints:

15\leq \sqrt{\left(x_2-x_4\right){}^2+\left(y_2-y_4\right){}^2}\leq 20

15\leq \sqrt{\left(x_4-x_5\right){}^2+\left(y_4-y_5\right){}^2}\leq 20

15\leq \sqrt{\left(x_2-x_5\right){}^2+\left(y_2-y_5\right){}^2}\leq 20

15\leq \sqrt{\left(x_1-x_2\right){}^2+\left(y_1-y_2\right){}^2}\leq 20

15\leq \sqrt{\left(x_1-x_5\right){}^2+\left(y_1-y_5\right){}^2}\leq 20

15\leq \sqrt{\left(x_1-x_3\right){}^2+\left(y_1-y_3\right){}^2}\leq 20

15\leq \sqrt{\left(x_3-x_5\right){}^2+\left(y_3-y_5\right){}^2}\leq 20

Solving this highly nonlinear system of equations with constraints is not a trivial problem! It fact, because of the high degree of nonlinearity and dimension of the problem, it is safe to assume that no closed-form solution exists, and therefore, must be solved numerically.

For this task, we used MATLAB, and experimented with the lsqnonlin() and fsolve() commands. The only issue is that (as with all such numerical algorithms) convergence depends very highly on the choice of initial conditions. It is very difficult to choose a priori this many initial conditions, so I wrote a script that randomized initial conditions. I then ran several numerical experiments and obtained the following results:

In the plot above, I have labeled the plots that converged to the triangle formation with the title “this one”. In addition, the five black circles denote the initial positions of the players on the court before they fill the triangles in the offense. One sees just by the diagram above, how difficult such a problem is to solve mathematically, even through a numerical approach. Running more trials would perhaps yield better results, but, it works! I am truly fascinated by this. In the coming days, I will work on optimizing the numerical algorithm, and post my updates as they come.

Here is an animation of one of the scenarios above when the algorithm converges correctly:

In this animation above, the black dots represent the positions of the players on the court. They begin at initial (random) positions and attempt to fill the triangles as described above.

Thanks for reading!

Breakdown of Game 7 between OKC and GSW

Here is the collection of time series of relevant predictor variables captured live during Game 7 of the Western Conference Finals between The Oklahoma City Thunder and The Golden State Warriors:

Another video animation:

Many commentators are making a point to mention how many three point shots The Warriors made, suggesting that that was the main reason why the Warriors won the game. However, the time series above show otherwise. As can be seen above, OKC’s loss of the lead in the game directly corresponds to GSW’s increase in 2PT %. This can be further confirmed by computing the correlations between OKC’s point difference and all of the other predictor variables plotted above:

One can see from these calculations that OKC’s point difference is strongly negatively correlated with the amount of personal fouls they committed during the game, the amount of personal fouls GSW committed during the game, and GSW 2PT% during the game.

Metrics for GSW vs. OKC Game 6 Second Half

Continuing with the live metrics employed yesterday, here is an analysis of the second half of the Warriors-Thunder Game 6. 

Here is a plot of the various time series of relevant statistical variables: 

One can see from this plot for example, the exact point in time when OKC loses control of the game. 

Further, here are the correlation coefficients of the variables above: 

One sees there is a tremendously strong anti-correlation between OKC’s lead and GSW 3PT%, while there is a somewhat strong correlation between OKC’s lead and their 2PT%. This perhaps means that for Game 7, OKC’s 3PT defense needs to greatly improve along with maintaining their 2PT%, which, as can be seen from the plot above, dropped off towards the end of the game. 

Live Metrics for NBA Games

Yesterday for the first time, I took the playoff game between Cleveland and Toronto as an opportunity to test out a script I wrote in R that keeps track of key statistics during a game in real time (well, every 30 seconds). Based on previous work, it is evident that championship-calibre teams are the ones that have excellent 2PT-FG% and the ability to draw fouls, so I tracked these during the game, and I came up with the following plot of several time series:

One sees for example that while Toronto started off the game with a much higher 2PT FG%, towards the end Cleveland ended up winning that battle.

A video of this animation is as follows (set the YouTube player to 1080p + FullScreen for Max Quality!)

An interesting question to ask is how are these series correlated? Well, let’s see:

In this correlation plot, “pd” indicates point difference, “PF” indicates personal fouls, “2PFG.” indicates 2-Point field goal percentage.

One sees immediately from the correlation plot above that there is a very strong correlation between Cleveland’s point difference  and Toronto’s personal fouls, with some strong correlations attributed to Cleveland’s 2-Point FG% as well.  The equal and opposite is true for Toronto’s point difference. It seems that during a game of this intensity in the playoffs, drawing fouls is a very important factor in determining which team leads and eventually wins in the game combined with 2-Point field goal percentage.

Basketball Paper Update

A few weeks ago, I published a paper that used data science / machine learning to detect commonalities between NBA playoff teams. I have now updated and extended it to detect commonalities between NBA championship teams using artificial neural networks, which is a field of deep learning. The paper can be accessed by clicking on the image below.

New Paper on Machine Learning and Basketball

A new and formal paper of mine describing how one can use machine learn methodologies to help determine which NBA teams will make the playoffs is now online: 

  1. arXiv link
  2. SSRN link

Have a look!