How to make calculations for a complex 3-D conduit shape? I'm an electrician running conduit horizontally along a wall at a height of 6 feet off the floor, when I come to a corner of the room. Normally, I would bend a 90-degree elbow and continue level along the adjacent wall, but there are complications.
In the corner, a vertical pipe, 7-inches outside diameter, is running from floor to ceiling. No problem, I would normally change strategies and use a double 45 (45+45) to cut neatly in front of the pipe to the adjacent wall. However, there is a locker with a shelf above it on the adjoining wall that the conduit will need to rise above. The top of the shelf is at 6'10", but I would like to rise to the 7-foot level mark.
And I want to do all of this in only two (2) bends!
I want the shape of the conduit through this corner, from a top view, to appear as a simple 45+45 inside corner, though I realize the hypotenuse of the triangle will actually be stretched out in order to make the 12" rise. Here are some rough sketches of what I mean.


First Question: If I use 45-degrees for the first bend, How do I calculate the distance from the adjacent wall to make the first bend in order for the conduit to pass just in front of the pipe? (assume the 7-inch pipe is tight up against both walls)
Second Question: How do I calculate the length of my inclined hypotenuse?
Third Question: If I make the first bend at 45-degrees and begin rolling the conduit toward the shelf, the conduit will need to be rotated in my bender out of the plane of the two legs of the first bend to correct the run back to level. How do I calculate the degree of rotation out of plane I should rotate before making the second 45-degree bend?
Fourth Question: Or am I wrong to assume two 45-degree bends can accomplish all of this? If so, what degrees would I need to use?
[Notes: I'm not sure these facts matter, but my conduit is approximately 3/4" in diameter, and the bend radius of the bender is 4-5/16". I do not yet understand how to use radians, but usually working with degrees in regular trigonometry has been close enough for conduit bending.]
 A: I think you are very lucky. With a 12" cubical box, a 7" pipe and a 1" conduit you get just the clearance you need. Two bends, at the same angle: 53.6041 degrees.
ECHO: "cutter rotation", 57.0849
The length of the diagonal part of the conduit is 20.2237" measured along the center of the conduit between the bends.
Between the bends you will have to rotate the conduit in the bender 57.0849 degrees.

In this openscad program you can make the 12" high box shorter along the side wall and longer along the back wall. Here's the picture with a 20" by 9" box.

The measurements are
ECHO: "length", 24.5357
ECHO: "side angle", 68.4808
ECHO: "back angle", 35.3989
ECHO: "bender rotation", 56.2994

Here's the program:
/*  
openscad program to calculate bending angles and lengths
routing a conduit around a pipe

https://math.stackexchange.com/questions/4460045/how-to-make-calculations-for-a-complex-3-d-conduit-shape 

Adjust dimensions of box so that conduit misses pipe.
Read lengths and angles in console output.

Ethan Bolker
June 2022
*/
// box at the corner  
height = 12 ;
boxback  = 20;    // along back wall
boxside  = 9;   // along side wall
pipe   = 7;    // pipe diameter
conduit = 1;   // conduit diameter

// points on conduit
// just outside the box
sidecorner = [boxside+conduit/2,conduit/2, conduit/2];
backcorner = [conduit/2,boxback+conduit/2, height-conduit/2];
// along the walls
sidewall = [1.2*boxside+conduit/2,conduit/2, conduit/2];
backwall = [conduit/2,1.2*boxback+conduit/2, height-conduit/2];
// conduit segments
diagonalconduit = backcorner - sidecorner;
sideconduit     = sidecorner-sidewall;
backconduit     = backwall - backcorner;

// normal vectors to conduit planes at corners 
// to determine rotation in bender
sidenormal = cross(sideconduit, diagonalconduit);
backnormal = cross(diagonalconduit, backconduit);

// output to console
echo("length", norm(diagonalconduit));
echo("side angle", angle(sideconduit, diagonalconduit));
echo("back angle", angle(backconduit, diagonalconduit)); 
echo("bender rotation", angle(backnormal,sidenormal));

// illustration
// draw the pipe
translate([pipe/2,pipe/2, 0])
cylinder(h=height, d=pipe,$fn=32);

// draw the conduit segment by segment
color("black",1.0) {
  hull(){point(sidecorner);point(backcorner);}
  hull(){point(sidecorner);point(sidewall);}
  hull(){point(backcorner);point(backwall);}
}

//draw the box
color("green",0.2)
cube([boxside, boxback, height] );

module point(position){
    translate(position)
    sphere(d=conduit,$fn=32 );
}


function angle (a,b)=atan2(norm(cross(a,b)),a*b);

Nice problem.
A: Using @EthanBolker's excellent diagram, let me label the axes:
$x$-axis, the axis leaving the frame at the bottom middle
$y$-axis, the axis leaving the top right of the frame
$z$-axis, the axis leaving the top left of the frame
Let $(a,0,0)$ and $(0,a,b)$ denote the opposite corners of the box traversed by the conduit, where $a=(2+\sqrt{2})\times\text{Pipe Radius}$ and $b$ is the vertical displacement of the second section of conduit.
Let $\vec{v}_1=\langle 1,0,0\rangle,\quad\vec{v}_2=\langle-a,a,b\rangle,\quad\vec{v}_3=\langle0,1,0\rangle$
Using the formula for the angle between two vectors we can determine that the acute angle for both bends (i.e. the angle between the handle of the conduit bender and the floor) is given by
$$ \theta=\arccos\left(\frac{a}{\sqrt{a^2+b^2}}\right)\tag{1} $$
But, as noted in the comments, one must still know how much to rotate the centerline of the bend when making the second bend. That amount can be determined by the angle between the normal vectors of the planes containing the two bends.
The two normal vectors are found by taking the cross products $\vec{v}_1\times\vec{v}_2$ and $\vec{v}_1\times\vec{v}_2$.
If my calculations are correct this indicated that the center line of the second bend must be rotated by an angle
$$ \phi=\arccos\left(\frac{a^2}{a^2+b^2}\right)\tag{2} $$
Clockwise or counter-clockwise? I have no intuition here, best to decide at the moment when the time is at hand.
