problem02
1 Write formula or code for the length of the shortest line segment
The lines can be represented as:
\[l_1: \vec{p}_1(\lambda_1) = \quad \vec{\mathbf{r}}_A + \lambda_1 (\vec{\mathbf{r}}_B-\vec{\mathbf{r}}_A)\]
\[l_2: \vec{p}_2(\lambda_2) = \quad \vec{\mathbf{r}}_C + \lambda_2 (\vec{\mathbf{r}}_D-\vec{\mathbf{r}}_C)\]
Hence, for two points on either lines, \(p_1\), \(p_2\), the distance is:
\[D(\lambda_1, \lambda_2) = \quad \left|\left| \mathbf{\vec{p}}_2 - \mathbf{\vec{p}}_1 \right|\right|_n\]
Which can be framed as an optimisation problem, minimum length, \(\hat{s}\):
\[\hat{s} = \quad \min_{\lambda_1, \lambda_2} || \left( \vec{\mathbf{r}}_A + \lambda_1 (\vec{\mathbf{r}}_B-\vec{\mathbf{r}}_A) - (\vec{\mathbf{r}}_C + \lambda_2 (\vec{\mathbf{r}}_D-\vec{\mathbf{r}}_C)) \right) ||_n\]
or,
\[\hat{s} \leftarrow D\left\{ \nabla D(\lambda_1, \lambda_2) = 0 \right\}\]
Note that in the code, we are optimising for distance squared, and the \(s\) symbols in the code represents the distance squared.
2 Also find the end points of the shortest line segment
The formulation above can be reused, the optimal lambdas \(\hat{\Lambda} = (\lambda_1, \lambda_2)\), correspond to the closest points through the equation of the lines.
\[\left(\hat{\lambda}_1, \hat{\lambda}_2\right) = \underset{\lambda_1, \lambda_2}{\operatorname*{argmin}} \left\{ D(\lambda_1, \lambda_2) \right\}\]
A specific example’s numerical output was given in the previous section.
3 Find the volume of the tetrahedron
For any 2d shape extended to a point, the volume is \(\frac{1}{3} \text{Base-Area} \times \text{height}\). Why? Take a slice, the planar dimensions reduce linearly to zero, so the area reduces quadratically. Integrate the function for the area as a function of the height from base to the tip.
This way, we can see that a tetrahedron is geometric one-sixth of a parallelapiped, therefore, volume \(V(\vec{\mathbf{r}}_a, \vec{\mathbf{r}}_b, \vec{\mathbf{r}}_c, \vec{\mathbf{r}}_d)\) is (assuming the vectors are in three dimensions for cross product to work):
\[V(\vec{\mathbf{r}}_a, \vec{\mathbf{r}}_b, \vec{\mathbf{r}}_c, \vec{\mathbf{r}}_d) = \frac{1}{6} \left|(\vec{\mathbf{r}}_c - \vec{\mathbf{r}}_b) \times (\vec{\mathbf{r}}_c - \vec{\mathbf{r}}_a) \cdot (\vec{\mathbf{r}}_d - \vec{\mathbf{r}}_d)\right|\]
4 Write formula or code for the tensions in the rods
\[\vec{\mathbf{F}} + T_{ad}\hat{r}_{ad} + T_{bd}\hat{r}_{bd} + T_{cd}\hat{r}_{cd} = \vec{\mathbf{0}}\]
There was an in-class mention about Cramer’s rule to solve this. There are three equations and three unknowns, but one could use Gaussian-elimination.
The other way to solve this using vector algebra is to dot the whole equation with a vector which is perpendicular to two of the three tension vectors. For example, dot the equation by \(\hat{r}_{cd} \times \hat{r}_{bd}\).