The Shadow Length

In The Shadow Angle we found a unit vector \(\hat{w}\) parallel to the shadow. Now we shall find the length \(L\) of the shadow, and therefore the shadow vector \(w = L \hat{w}\).
import sympy as sp
from sympy import sin
from sympy.abc import D
from analemma.algebra import frame, render, result
Solving the Shadow Triangle
We can find \(L\) by forming \(w(\lambda) = g + \lambda s\) and enforcing that this vector lies in the dial face by solving \(w(\lambda) \wedge G = 0\) for \(\lambda\). It will be useful to separate the numerator and denominator by writing \(\lambda = \frac{N}{D}\).
.
render.expression(r"\lambda \equiv \frac{N}{D}", result.shadow_triangle_solution())
\[\displaystyle
\begin{equation}
\lambda \equiv \frac{N}{D} = \frac{\sin{\left (i \right )} \sin{\left (\iota \right )} \cos{\left (d \right )} + \cos{\left (i \right )} \cos{\left (\iota \right )}}{\left(\left(\sin{\left (i \right )} \cos{\left (d \right )} \cos{\left (\theta \right )} - \sin{\left (\theta \right )} \cos{\left (i \right )}\right) \cos{\left (\mu_{s} \right )} - \sin{\left (\mu_{s} \right )} \sin{\left (d \right )} \sin{\left (i \right )}\right) \sin{\left (\Xi_{s} \right )} + \left(\sin{\left (i \right )} \sin{\left (\theta \right )} \cos{\left (d \right )} + \cos{\left (i \right )} \cos{\left (\theta \right )}\right) \sin{\left (\alpha \right )} \cos{\left (\sigma \right )}} \nonumber
\end{equation}
\]
where the subscript \(s\) on the hour angle \(\mu_s\) and sunray-gnomon angle \(\Xi_s\) indicates that they are to be evaluated under the condition \(\iota = \theta\). This is true when the gnomon is parallel to the earth's axis, and termed a style, hence the subscript \(s\).
Given the above solution for \(\lambda\), we now have \(w\) in principle. However, it is a little cumbersome to work with and we can get \(w\) in terms of \(g\)-\(\lambda s\)-\(w\) triangle directly by projecting \(w\) onto \(s\) and \(g\) to give two equations we can solve for \(\lambda\) and \(L\), the length of \(w\). We have
\[s\cdot w = L\cos(\Xi-\beta) = s\cdot g + \lambda\, s\cdot s = \cos(\Xi) + \lambda\]
and
\[g\cdot w = L\cos(\beta) = g\cdot g + \lambda g\cdot s = 1 + \lambda\, \cos(\Xi)\]
This yields two simultaneous equations for \(\lambda\) and \(L\), with solutions
\[\lambda = \frac{\sin(\beta)}{\sin(\Xi-\beta)}\]
and
\[L = \frac{\sin(\Xi)}{\sin(\Xi-\beta)} = \frac{N \sin(\Xi)}{D \sin(\beta)}\]
Angle between Gnomon and Shadow
Given that \(\sin(\beta)\) appears in the solution for \(\lambda\), it will be useful to have its explicit form, which is
sin_beta, cos_beta = result.gnomon_shadow_angle_sincos()
render.expression(r"\tan(\beta)", sin_beta/cos_beta)
\[\displaystyle
\begin{equation}
\tan(\beta) = \frac{\sin{\left (i \right )} \sin{\left (\iota \right )} \cos{\left (d \right )} + \cos{\left (i \right )} \cos{\left (\iota \right )}}{\left(\sin{\left (i \right )} \cos{\left (d \right )} \cos{\left (\iota \right )} - \sin{\left (\iota \right )} \cos{\left (i \right )}\right) \cos{\left (\mu \right )} - \sin{\left (d \right )} \sin{\left (i \right )} \sin{\left (\mu \right )}} \nonumber
\end{equation}
\]
The (sine of the) angle \(\Psi\) between the dial face and the plane containing the shadow and gnomon cancels in the ratio of \(\sin(\beta)\) and \(\cos(\beta)\) above:
render.expression(r"\sin(\beta)", sin_beta)
\[\displaystyle
\begin{equation}
\sin(\beta) = \frac{\sin{\left (i \right )} \sin{\left (\iota \right )} \cos{\left (d \right )} + \cos{\left (i \right )} \cos{\left (\iota \right )}}{\sin{\left (\Psi \right )}} \nonumber
\end{equation}
\]
The numerator of \(\sin(\beta)\) is equal to \(N\), the numerator of \(\lambda\), and so we have that
\[\sin(\beta) = \frac{N}{\sin(\Psi)}\]
and so
\[L = \frac{\sin(\Xi)\sin(\Psi)}{D}\]
The Shadow Vector
Given this form of \(L\), we can express the shadow vector as follows.
Gn = frame.dialface()
Sn = result.shadow_bivector_explicit()
w_hat = result.unit_shadow(Gn, Sn)
Xi = sp.Symbol(r"\Xi")
render.align(
r"D\, w = D\,L\,\hat{w}",
D*result.shadow_length()*w_hat,
lambda coeff : sp.collect(coeff, sin(Xi)))
\[\displaystyle \begin{align} D\, w = D\,L\,\hat{w} & = \left(\left(\sin{\left (d \right )} \sin{\left (i \right )} \sin{\left (\iota \right )} \sin{\left (\mu \right )} + \cos{\left (i \right )} \cos{\left (\mu \right )}\right) \sin{\left (\Xi \right )}\right) n_1 \nonumber \\ &\left(\left(- \sin{\left (i \right )} \sin{\left (\iota \right )} \sin{\left (\mu \right )} \cos{\left (d \right )} - \sin{\left (\mu \right )} \cos{\left (i \right )} \cos{\left (\iota \right )}\right) \sin{\left (\Xi \right )}\right) n_2 \nonumber \\ &\left(\left(- \sin{\left (d \right )} \sin{\left (i \right )} \sin{\left (\mu \right )} \cos{\left (\iota \right )} + \sin{\left (i \right )} \cos{\left (d \right )} \cos{\left (\mu \right )}\right) \sin{\left (\Xi \right )}\right) n_3& \nonumber \end{align}\]
Next, in The Analemma, we evaluate the caresian coordinates of the shadow vector, to yield formulae for the analemma.