Is there an existing theory of Pythagorean triples for numbers of the form $p+q\sqrt r$ rather than integers? Before Christmas I was teaching a class about surds. They were able to simplify, add, multiply etc.
To give them one application of this, I wanted to give them some triangles that they would have to identify as right-angled or not.
I wanted to avoid obvious multiples of usual integer Pythagorean triples, so I used a brute force search of surds of the form $p+q\sqrt2$ to find a few like this:
$T_1: a=1+\sqrt2$, $b=1+\sqrt2$, $c=2+\sqrt2$
$T_2: a=2+\sqrt2$, $b=2+\sqrt2$, $c=2+2\sqrt2$
$T_3: a=1+2\sqrt2$, $b=1+2\sqrt2$, $c=4+\sqrt2$
$T_4: a=2+2\sqrt2$, $b=2+2\sqrt2$, $c=4+2\sqrt2$
$T_5: a=4+\sqrt2$, $b=4+\sqrt2$, $c=2+4\sqrt2$
$T_6: a=1+2\sqrt2$, $b=4+2\sqrt2$, $c=5+2\sqrt2$
$T_7: a=4+\sqrt2$, $b=4+4\sqrt2$, $c=4+5\sqrt2$
$T_8: a=2+\sqrt2$, $b=4+4\sqrt2$, $c=6+3\sqrt2$
It turns out that $T_1, T_2, T_3, T_4, T_5$ are all multiples of each other - some more obvious than others.
$T_6$ and $T_7$ are also multiples of each other. 
This raises a number of questions for me:
1) Has work on this kind of thing already been done? Is there a good reference work on this topic?
2) What do we call these kinds of numbers? They aren't integers, but they aren't "Gaussian integers" because those take the form $x+yi$, whereas I want the form to be $p+q\sqrt r$ 
3) Is there a standard way to identify the primitive triples?
4) Instead of a brute force approach I know I can use the usual Euclid's formula to generate them, too, but then what are a "good" set of values to start with - and will I achieve all primitives using that method?
5) I have also read of a set of transformations that will generate all primitive triples starting from $(3,4,5)$ - can I use that set of transformations starting from ...?
 A: Here are some partial answers:


*

*Primitive Phythagorean Triples of Gaussian Integers,
by James T. Cross. 
Mathematics Magazine,
Vol. 59, No. 2 (Apr., 1986), pp. 106-110
DOI: 10.2307/2690428.

*A Ring of Pythagorean Triples over Quadratic Fields,
by C. Somboonkulavudi and A. Harnchoowong.
Ukrainian Mathematical Journal, 
June 2014, Volume 66, Issue 1, pp 153–159
DOI: 10.1007/s11253-014-0918-7
The first paper says:

The primitive Pythagorean triples in $\mathbb Z[\sqrt{-1}]$ are parametrised by $(\frac{a^2+b^2}{2},\frac{a^2-b^2}{2i},ab)$, where $a,b \in \mathbb Z(\sqrt{-1})$ are relatively prime, with positive odd real parts.

A: One of the simplest cases is the algebraic integers having the form $a+b\sqrt{-2}$, with $a,b$ each ordinary integers.  As many readers know this is a unique factorization domain.  It's also a parity defined domain.  We can define the even/odd parity of $a+b\sqrt{-2}$ as that of just $a$.  The reader can verify that this definition fits with the expected relations:
(odd)+(odd) = (even)+(even) = (even)
(odd)+(even) = (even)+(odd) = (odd)
(odd)x(odd) = (odd)
(odd)x(even) = (even)x(odd) = (even)x(even) = (even)
The domain also contains one even prime, $\pm \sqrt{-2}$, which is a common factor of all even elements.
We can argue the same way as we do for ordinary integers.  A primitive triple $(x, y, z)$ must contain two odd and one even elements, so we are sure that the hypotenuse $z$ and at least one leg $x$ have opposite parity.  Since $(z+x)(z-x)=y^2$ is the product of two odd factors that must be relatively prime, we have 
$z+x =m^2$
$z-x = n^2$
with $m, n$ odd and relatively prime.  Then we have the formulation that applies to ordinary integers as well:
$x = (m^2-n^2)/2$
$y = mn$
$z = (m^2+n^2)/2$.
For example, we may take $m = 1, n = 1+\sqrt{-2}$ to get $(x, y, z)=(1-\sqrt{-2}, 1+\sqrt{-2}, \sqrt{-2})$.
Unlike ordinary integers, this domain allows an even primitive hypoteneuse, but this has no impact on the analysis. 
Interestingly, we cannot apply this method to all quadratic UFDs because we cannot generally define parity.  Try it for algebraic integers having the form $a+b \sqrt{-3}$.
A: If you take something like $X = x+y\sqrt n$ and $Y = a + b\sqrt n$, then $(X+iY)^2$ will give you a pythagorean triplet. 
