23.
Here I will show you how to get the angle φ from the angle θ.
24.
Let's work on the triangle located at the midplane of the pyramid.
The triangle is painted with a light blue color in the step #23.
By using the Pythagorean theorem, we can get the length of S.