## Problem

Determine the position of the blue ramp with:

width  meters and slope  %
when the red slopes have:
depth  meters and slope  degrees.

## Result

The blue ramp has:

length meters and angle degrees.
and the small side of the green triangle has:
length meters.

## Details

Below, the problem is described geometrically in the horizontal plane, turned into a 4th power polynomial equation, of which a direct, general solution is known since the Renaissance works of Ferrari (and Vieta).

Files are then shortly described, which implement this general solution.

### Problem

The goal is to determine the position of blue ramp going down from the top of the red slopes to their bottom (all three are rectangles).

Both steep red slopes have the same $$depth$$ and $$slope_{red}$$, thus the same projected «horizontal width»: $qq_{red}~\buildrel\triangle\over =~ \frac{depth}{slope_{red}}$ where for example $$slope_{red} = tan(\pi\frac{60}{180})$$ (60-degree red slopes).

The blue ramp has a given $$width_{blue}$$ and a given $$slope_{blue}$$, and thus a projected «horizontal length»: $horizlength_{blue}~\buildrel\triangle\over =~\frac{depth}{slope_{blue}}$ where $$slope_{blue} < slope_{red}$$, for example $$slope_{blue} = 0.25 ~~(25\%)$$.

### Problem, projected onto the horizontal plane

#### Constraints

The green triangle is horizontal. The leftmost corner of the blue ramp $$i \cdot zz$$ must be at the top of the red slope.

The origin $$O$$, the nearby corner of the blue ramp $$yy \cdot exp(i \cdot angle)$$, and the rightmost corner of the blue ramp $$xx + i \cdot qq$$ must be colinear. The latter must also be at the bottom of the red slope.

The problem is fully determined by $$qq$$, $$horizlength$$ and $$width$$. To find the position of the blue ramp, we need to determine $$xx$$, $$yy$$, $$zz$$ and $$angle$$.

### Equation

Since the ramp is rectangular, $$angle$$ appears at several locations. Expressing for example $$tan(angle)$$, one can show that: $qq \cdot width=xx \cdot yy$ Squaring both sides and using the Pythagorean theorem to express $$xx^2$$, one obtains: $f(yy)=0$ where: $f(yy)~\buildrel\triangle\over =~yy^2 \cdot ((horizlength+yy)^2-qq^2)-qq^2 \cdot width^2$ which is a 4th power polynomial in $$yy$$. The other variables $$xx$$, $$zz$$ and $$angle$$ can all be derived from $$yy$$.

### Direct solution

Fortunately, the 4th power is the highest degree that can be algebraically solved [1][2] using a direct, general solution, which I decided to implement, so as to have reusable code. I chose Ferrari's solution [3], including Vieta's substitution in the depressed cubic case [4].

### Files

Code I wrote to solve the problem:

### Acknowledgments

Thanks to Felix Schädler for the initial request, and to the authors of three.js and MathJax for their excellent softwares.

### References

  This HTML page contains the mathematical description of a problem
and its solution, an interactive numerical demo and 3D demo, and
links to the programs I wrote to implement the solution.

you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software