Number of grid points satisfying the triangle inequality Background: The following questions arise from the Wigner $3j$ symbol, see here. It is well known that the angular momenta $(j_1,j_2,j_3)$ in the Wigner $3j$ symbol must satisfy the triangle inequality.
Q1:
Assume three nonnegative integer numbers $J_1,J_2,J_3\in \mathbb{N}$.
I would like to know how to calculate the total number of the triplet $(j_1,j_2,j_3)$ satisfying the triangle inequality, see Eq. (34.2.1) here
$$
|j_1-j_2|
\leq j_3
 \leq j_1+j_2,
$$
where $j_i=0,1,...,J_i,i=1,2,3$.
The total number is denoted by $N(J_1,J_2,J_3)$.
It is clear that the total number of the triplet $(j_1,j_2,j_3)$ without satisfying the triangle inequality is
$$
M(J_1,J_2,J_3) = (J_1+1)(J_2+1)(J_3+1).
$$
To make the question clear, here lists the results for some values.
It is observed that $N\approx M/2$.




$J_1$
$J_2$
$J_3$
$M$
$N$




0
0
0
1
1


1
0
0
2
1


1
1
0
4
2


1
1
1
8
5


2
0
0
3
1


2
1
0
6
2


2
1
1
12
6


2
2
1
18
9


2
2
2
27
15




Q2:
Assume the set $A$ contains all the triplets $(j_1,j_2,j_3)$ satisfying the triangle inequality for given numbers $J_1,J_2,J_3$.
The total number of elements is $N$ as mentioned above.
How to effectively index the element of $A$?
It means that we need to find a relation between the index $j = 0, 1, ..., N$ and the triplet $(j_1,j_2,j_3)$ satisfying the triangle inequality.
 A: Suppose $J_1 \le J_2 \le J_3$ and first suppose $J_3 \ge J_1+J_2$. Then whatever the values of $j_1$ and $j_2$, any value of $j_3$ completing the triangle inequality is possible. So the number of triples is $$\sum_{j_1=0}^{J_1}\sum_{j_2=j_1}^{J_2} (2j_1+1)+ \sum_{j_1=1}^{J_1}\sum_{j_2=0}^{j_1-1}(2j_2+1) $$ which gives $N(J_1, J_2,J_3)=\frac{1}{3}(J_1+1)\big(3(J_1J_2+J_2+1)+J_1-J_1^2\big)$.
If, on the other hand, $J_3<J_1+J_2$, you need to take away from this the triangles that become impossible because you can't select a sufficiently large $j_3$. There are $$\sum_{j_1=J_3-J_2+1}^{J_1}\sum_{j_2=J_3-j_1+1}^{J_2} (J_2-J_3+j_1)$$ of these which is $\frac{1}{6}(J_1+J_2-J_3)(J_1+J_2-J_3+1)(J_1+J_2-J_3+2)$.
I think these agree with the special cases in the comments.
A: Not an answer but some asymptotics.
For large $J_k$, we can assume real coordinates, and expect that $p=N/M$ tends to the probability that the real random variables $x,y,z$, chosen uniformly inside a box of lengths $(a,b,c)$, satisfy the triangle inequality.
The case $a=b=c=1$ is simple and indeed gives $p=1/2$.
Because of symmetry and scaling invariance, we can assume WLOG $a\le\ b \le c$, and $a=1$. (In the original setting, this corresponds to assume $J_3 \ge J_2 \ge J_1 \gg 1$, and set $b=J_2/J_1$, $c= J_3/J_1$)
To compute $p(b,c)$ in general, we need to compute $p(b,c)=\frac{1}{bc}I(b,c)$ where $$I(b,c)= \int_{0}^1 \int_{0}^b  [\min(c,x+y) - |x-y|] \, dy \,dx $$
There are several ranges to consider, I'll compute the two extremes.
For the range $c\le 2$ (not too dissimilar sides) (which includes the $b=c=1$ case) we get
$$I(b,c)=\frac12(c+b-1) -\frac12(c-b)^2 +\frac16(c-b)^3$$
For the range $c \ge b+1$ we get
$$I(b,c)= b-\frac13$$
and $p(b,c)=\frac{1}{c}-\frac{1}{3bc}$. This agrees (asympotically) with the first answer by @mcd.
