I am trying to display a $3D$ Pipe with $90°$ bend. I am writing code for it, but I am sure this is more of a mathematical question as a programming one.
It would be nice if anyone could help me with the formula of displaying this bend. The $90°$ bend is basically the top left quarter of a circle.
If you put 4 of these pieces together you would get a torus. So you just need to consider a parametric equation for a torus but restrict to a subset of the domain of the parameters. If you want the radius of the cross section of the pipe to be $a$, and the distance from the center of the bend of the pipe to the center of one of the cross sectional circles to be $c$, then a parametric representation is given by (in radians) $$\begin{array}{rcl} x & = & (c+a\cos v)\cos u \\ y & = & (c+a\cos v)\sin u\\ z & = & a\sin v \end{array}$$
where $v\in [0,2\pi)$ and $u\in [0,\pi/2]$ (in degree this would be $v\in [0,360)$ and $u\in [0,90]$). If you let $u$ run over some different range then you will get different lengthed 'segments' of the torus, so for instance if $u$ was allowed to run through $[0,\pi]$ then you would sweep out a full half torus, or a 180 degree bend.