I'm not sure this helps because I don't understand the function completely. The formula I've alway seen for generating triples is:
$$A=m^2-n^2\qquad B=2mn\qquad C=m^2+n^2$$
and it is useful but it generates extraneous and trivial triples if $m\le n$; it also generates doubles and odd-or-even square multiples of primitive triples. We can generate triples for all $m,n\in\mathbb{N}$ where $GCD(A,B,C)$ is an odd square (which include all primitives) and get distinct $sets$ of triples by replacing $(m,n)\text{ with }((2m-1+n),n).$ Expanded, this becomes:
$$A=(2m-1)^2+2(2m-1)n\quad B=2(2m-1)n+2n^2\quad C=(2m-1)^2+2(2m-1)n+2n^2$$ and the result is as shown in the sample below.
$$\begin{array}{c|c|c|c|c|}
\text{$Set_n$}& \text{$Triple_1$} & \text{$Triple_2$} & \text{$Triple_3$} & \text{$Triple_4$}\\ \hline
\text{$Set_1$} & 3,4,5 & 5,12,13& 7,24,25& 9,40,41\\ \hline
\text{$Set_2$} & 15,8,17 & 21,20,29 &27,36,45 &33,56,65\\ \hline
\text{$Set_3$} & 35,12,37 & 45,28,53 &55,48,73 &65,72,97 \\ \hline
\text{$Set_{25}$} &2499,100,2501 &2597,204,2605 &2695,312,2713 &2793,424,2825\\ \hline
\end{array}$$
In all cases, $m$ is the set number and $n$ is the $n^{th}$ member of the set.
We can see that $f(2,3)=(27,36,45)$ is $9\text{ times }(3,4,5)$ and this is because $(2m-1)=(2*2-1)=3$, and $GCD((2m-1),n)=3.$ Whenever $GCD((2m-1),n)=1$, a primitive will be generated; otherwise, an odd square multiple will be generated. Only in $Set_1 (m=1)$ or (rotated $90^\circ$), in the first member of each set $(k=1)$, are all triples primitive and these can be generated by
$$\text{For }m=1:\quad A=2k+1\qquad B=2k^2+2k\qquad C=2k^2+2k+1$$
$$\text{For }k=1:\quad A=4m^2-1\qquad B=4m\qquad C=4m^2+1$$
Note that prime values of $C$ can appear in all sets but prime values of $A$ can only appear in $Set_1(m=1)$ because $$A=(2m-1)^2+2(2m-1)n=(2m-1)(2m-1+2n)$$ so $m>1$ results in a composite number $A$.
If you need help finding triples for given sides see this.
I hope this helps in your search for primitives and primes.