> For the complete documentation index, see [llms.txt](https://changsin.gitbook.io/math/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://changsin.gitbook.io/math/linear-algebra/week4/practice-using-non-square-matrices-to-do-a-projection.md).

# Practice: Using non-square matrices to do a projection

## 1. Shadow projection

Shadows are an example of a transformation that reduces the number of dimensions. For example, 3D objects in the world cast shadows on surfaces that are 2D.

We can consider an example for looking at shadows using linear algebra.![](https://d3c33hcgiwev3.cloudfront.net/imageAssetProxy.v1/JV_KjNldEeew6w5E8nrYDg_8304b0a141aa3fc405b898ca13f576a3_shadows.png?expiry=1612828800000\&hmac=C3e-RZaJ-DLUnPusYKe_sXEW-YsHLmUjs1Ly3pv62Mg)

The sun is sufficiently far away that effectively all of its rays come in parallel to each other. We can describe their direction with the unit vector$$\hat{s}$$.

We can describe the 3D coordinates of points on objects in our space with the vector $$r$$. Objects will cast a shadow on the ground at the point $$r'$$ along the path that light would have taken if it hadn't been blocked at $$r$$, that is, $$r' = r + \lambda \hat{s}$$.

&#x20;The ground is at $$r'\_3 = 0$$; by using $$r' \cdot \hat{e}\_3 = 0$$, we can derive the expression, $$r \cdot \hat{e}\_3 + \lambda s\_3 = 0$$, (where $$s\_3 = \hat{s} \cdot \hat{e}\_3$$​).

Rearrange this expression for $$\lambda$$ and substitute it back into the expression for $$r'$$ in order to get $$r'$$ in terms of $$r$$.

{% tabs %}
{% tab title="First Tab" %}
From the lecture video, we know that the projection and the dot product are the same things, which result in dimension reduction: e.g., 3D -> 2D as in the current case. The first two problems are just pure linear algebra to express the formula in different forms.

$$(1) r^′=r+λs ̂$$

$$(2) r\_3^′=0$$

The subscript refers to the dimension, the third dimension in this case, which is the vertical line. For r', there is no third dimension since it is 2D and thus it equals zero.

$$(3) r^′⋅e ̂\_3=0$$

r' is perpendicular to the vertical line and thus the dot product of the two vectors is zero.

$$(4) s\_3=s ̂⋅e ̂\_3$$

$$s ̂⋅e ̂\_3$$ is the projection of $$s ̂$$ onto $$e ̂\_3$$ which is $$s\_3$$

$$(5) r⋅e ̂\_3+λs\_3=0$$

From (1), if we dot product both sides by $$e ̂\_3$$, we get:

$$(1−1) r^′⋅e ̂\_3=(r+λs ̂)⋅e ̂\_3$$

Since we know, $$(3) r^′⋅e ̂\_3=0$$:

$$(1−2) 0=(r+λs ̂ )⋅e ̂\_3$$

Or

$$(1−3) r⋅e ̂\_3+λs ̂ ⋅e ̂\_3=0$$

Finally, from (4), we get (5)

If we rearrange (5) in terms of λ

$$(5−1) λ=−(r⋅e ̂\_3)/s\_3$$

Plugging it into (1), we get:

$$(6) r^′=r − s ̂(r⋅e ̂\_3)/s\_3$$

Which is the answer for #1

If we apply Einstein's convention on (6):

$$(7) r\_i^′=r\_i −s\_i \[e ̂\_3]\_{j} r\_j/s\_3$$

$$r\_3$$ is the projection of r to $$e ̂\_3$$:

$$(8) r\_i^′=r\_i −s\_i r\_3/s\_3$$

From (7), if we take $$r$$ as the common term:

$$(7−1) r\_i^′=(I\_ij −(s\_i \[e ̂\_3]\_j/s\_3 ) r\_j$$

Similarly, from (8), we get:

$$(8−1) r\_i^′=(I\_ij − s\_i I\_{3j}/s\_3 ) r\_j$$
{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}
