Mathematics Behind The Triangle Offense

It was pointed out to me recently that a few of the articles I have written describing the detailed geometric structure behind the triangle offense is scattered in various places around my blog, so here is a list of the articles in one convenient place: 

  • The Mathematics of Filling the Triangle (First article) 
  • Group Theory and Dynamical Systems Theory Behind The Triangle Offense 
  • A Demonstration That The Triangle Offense is the most efficient/optimal way for 5 players to space the floor.
  • By: Dr. Ikjyot Singh Kohli (About the Author)

    1. The Mathematics of Filling the Triangle (First article) 
    2. Group Theory and Dynamical Systems Theory Behind The Triangle Offense 
    3. A Demonstration That The Triangle Offense is the most efficient/optimal way for 5 players to space the floor.

    By: Dr. Ikjyot Singh Kohli (About the Author)

    Basketball – A Game of Geometry

    In a previous post, I described the most optimal offensive strategy for the Knicks based on developing relevant joint probability density functions.

    In this post, I attempt a solution to the following problem:

    Given 5 players on the court, how can one determine (x,y) coordinates for each player such that the spacing / distance between each player is maximized. Thus, mathematically providing a solution in which the arrangement of these 5 players is optimal from an offensive strategy standpoint. The idea is that such an arrangement of these 5 players will always stretch the defense to the maximum.

    The problem is then stated as follows. Let (x_i, y_i) be the x and y coordinates of player i on the court. We wish to solve:


    Problems of this type are known as multi-objective optimization problems, and in general are quite difficult to solve. Note that in setting up the coordinate system for this problem, we have for convenience placed the basket at (x,y) = (0,0), i.e., at the origin.

    Now, for solving this problem we used the Non-dominated Sorting Genetic Algorithm-II (NSGA-II) in the MCO package in R.

    In general, what I found were that there are many possible solutions to this problem, all of which are Pareto optimal. Here are some of these results.





    Here are some more plots of of player coordinates clearly showing the origin point (which as mentioned earlier, is the location of the basket):

    Each plot above shows the x-y coordinates of players on the floor such that the distance between them is a maximum. Thus, these are some possible configurations of 5 players on the floor where the defense of the opposing team would be stretched to a maximum. What is even more interesting is that in each solution displayed above, and indeed, each numerical solution we found that is not displayed here, there is at least one triangle formation. It can therefore be said that the triangle offense is amongst the most optimal offensive strategies that produces maximum spacing of offensive players while simultaneously stretching the defense to a maximum as well. Here is more on the unpredictability of the triangle offense and its structure. 

    Based on these coordinates, we obtained the following distance matrices showing the maximum / optimal possible distance between player i and player j:


    Above, we show 5 possible distance matrices out of the several generated for brevity. So, one can see that looking at the fifth matrix for example, players are at a maximum and optimal distance from each other if for example the distance between player 1 and 2 is 9.96 feet, while the distance between player 3 and 4 is 18.703 feet, while the distance between player 4 and 5 is 4.96 feet, and so on.

    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!