To Top
# Table of Contents 1. [Snell's Law](#snell) 2. [Dot Product](#dot-prod) 3. [Reflection](#reflection) 4. [Refraction](#refraction) 5. [Cross Product](#cross-prod) 5. [Row, Column and Null Space](#row-column-and-null-space) # Snell's Law
[(Adapted from here)](https://math.stackexchange.com/questions/153775/simple-proof-for-snells-law-of-refraction)
Light travelling along the green lines takes the same amount of time *t* seconds to travel. Let the medium at the top be A, and the one at the bottom be B, and so the length of the green line in medium A be D_A and the one in medium be D_B. The red line is labeled x. $$ V_{A} = \frac{c}{n_1}\ \ and \ \ V_{B} = \frac{c}{n_2} \\ \\ D_A = V_A \times t = \frac{c \times t}{n_1} \\ D_B = V_B \times t = \frac{c \times t}{n_2} \\ So:\\ \frac{D_A}{D_B} = \frac{n_2}{n_1} \\ \\ sin(\theta_i) = \frac{D_A}{x} \\ sin(\theta_r) = \frac{D_B}{x} \\ So:\\ \frac{sin(\theta_i)}{sin(\theta_r)} = \frac{D_A}{D_B} = \frac{n_2}{n_1} \\ \\ Therefore:\\ n1 \times sin(\theta_i) = n_2 \times sin(\theta_r)V_{A} = \frac{c}{n_1}\ \ and \ \ V_{B} = \frac{c}{n_2} \\ \\ D_A = V_A \times t = \frac{c \times t}{n_1} \\ D_B = V_B \times t = \frac{c \times t}{n_2} \\ So:\\ \frac{D_A}{D_B} = \frac{n_2}{n_1} \\ \\ sin(\theta_i) = \frac{D_A}{x} \\ sin(\theta_r) = \frac{D_B}{x} \\ So:\\ \frac{sin(\theta_i)}{sin(\theta_r)} = \frac{D_A}{D_B} = \frac{n_2}{n_1} \\ \\ Therefore:\\ n1 \times sin(\theta_i) = n_2 \times sin(\theta_r) $$
Dot Product
p ⋅ q can be thought of as the projection of p onto q.
Or p ⋅ q can be thought of as the component of p parallel to q, multiplied by the length of q.
3b1b Dot Products
(explains intuition behind the dot product formula nicely)
$$ p = \begin{bmatrix} p_1 \\ p_2 \end{bmatrix}, \ q = \begin{bmatrix} q_1 \\ q_2 \end{bmatrix} \\ \\ \overrightarrow{pq} = \begin{bmatrix} q_1 - p_1 \\ q_2 - p_2 \end{bmatrix} \\ \\ Get\ the\ lengths:\\ ||p||^2 = p_1^2 + p_2^2\\ ||q||^2 = q_1^2 + q_2^2 \\ ||\overrightarrow{pq}||^2 = q_1^2 + p_1^2 + q_2^2 + p_2^2 - 2p_1q_1 - 2p_2q_2 \\ \\ (Cosine\ formula):\\ a^2 = b^2 + c^2 - 2bc\cos(a)\\ (The\ angle\ opposite\ \overrightarrow{pq}\ is\ \theta\ (angle\ a)):\\ q_1^2 + p_1^2 + q_2^2 + p_2^2 - 2p_1q_1 - 2p_2q_2 = p_1^2 + p_2^2 + q_1^2 + q_2^2 - 2\sqrt{(p_1^2 + p_2^2)(q_1^2 + q_2^2)}\cos(\theta)\\ (Terms\ cancel\ out)\\ -2(p_1q_1 + p_2q_2)=-2\sqrt{(p_1^2 + p_2^2)(q_1^2 + q_2^2)}\cos(\theta)\\ p_1q_1 + p_2q_2=\sqrt{||p||^2||q||^2}\cos(\theta)\\ \\ Dot\ product\ is: p\cdot q=p_1q_1+p_2q_2, \ so:\\ p \cdot q = \sqrt{||p||^2||q||^2}\cos(\theta) $$ The explanation with the 3b1b video can be combined with the following fact to make sense of the dot product geometrically: $$ \begin{pmatrix} a\\ b \end{pmatrix} \cdot \begin{pmatrix} c\\ d \end{pmatrix} \\ = ( \begin{pmatrix} a\\ 0 \end{pmatrix} + \begin{pmatrix} 0\\ b \end{pmatrix} ) \cdot ( \begin{pmatrix} c\\ 0 \end{pmatrix} + \begin{pmatrix} 0\\ d \end{pmatrix} ) \\ = \begin{pmatrix} a\\ 0 \end{pmatrix} \cdot \begin{pmatrix} c\\ 0 \end{pmatrix} + \begin{pmatrix} a\\ 0 \end{pmatrix} \cdot \begin{pmatrix} 0\\ d \end{pmatrix} + \begin{pmatrix} 0\\ b \end{pmatrix} \cdot \begin{pmatrix} c\\ 0 \end{pmatrix} + \begin{pmatrix} 0\\ b \end{pmatrix} \cdot \begin{pmatrix} 0\\ d \end{pmatrix} \\ = ac(\begin{pmatrix} 1\\ 0 \end{pmatrix} \cdot \begin{pmatrix} 1\\ 0 \end{pmatrix}) + ad(\begin{pmatrix} 1\\ 0 \end{pmatrix} \cdot \begin{pmatrix} 0\\ 1 \end{pmatrix}) + bc(\begin{pmatrix} 0\\ 1 \end{pmatrix} \cdot \begin{pmatrix} 1\\ 0 \end{pmatrix}) + bd(\begin{pmatrix} 0\\ 1 \end{pmatrix} \cdot \begin{pmatrix} 0\\ 1 \end{pmatrix}) \\ = ac + bd $$
Here's a proof of why the dot product is distributive
, and it neatly extends the idea of dot products being projections onto unit vectors, and reflecting them.
Reflection
$$ Vertical\ component\ of\ incident\ ray:\ R_v \\ R_v = -(-R \cdot n)n = (R\cdot n)n \\ \\ R' = R - 2\cdot R_v \\(this\ is\ because\ R'\ is\ just\ R\ but\ the\ vertical\ component\ flipped) \\ R' = R - 2\cdot (R \cdot n)n $$
Refraction
$$ Perpendicular\ to\ normal\ component:\ V_\perp \\ Parallel\ to\ normal\ component:\ V_\parallel \\ \\ R_\perp = R + (-R \cdot n)n = R+cos(\theta_i)n \\ (since \ (-R)\cdot n = cos(\theta_i)) \\ \\ sin(\theta_i) = \frac{|R_\perp|}{|R|} = |R_\perp| \ \ (magnitude\ of\ 1) \\ sin(\theta_r) = \frac{|R'_\perp|}{|R'|} = |R'_\perp| \\ \\ n_1 \times sin(\theta_i) = n_2 \times sin(\theta_r) \\ sin(\theta_r) = \frac{n_1}{n_2}\times sin(\theta_i) \\ |R'_\perp| = \frac{n_1}{n_2}\times |R_\perp| $$ However, since the directions are the same we can multiply by a unit vector in the correct direction to get both vectors: $$ R_{\perp\ normalized} = X = \frac{R_\perp}{|R_\perp|}\\ X \cdot |R'_\perp| = X \cdot \frac{n_1}{n_2}|R_\perp|\\ R'_\perp = \frac{n_1}{n_2}R_\perp\\ R'_\perp = \frac{n_1}{n_2} \times (R + cos(\theta_i)n) \\ \\ |R'|^2 = |R'_\perp|^2 + |R'_\parallel|^2 \\ |R'_\parallel| = \sqrt{1 - |R'_\perp|^2} \\ (The\ magnitude\ of\ R'\ is\ 1) \\\\ Since\ R'_\parallel\ is\ parallel\ to\ the\ normal\ vector,\ we\ can\\ multiply\ its\ magnitude\ by\ the\ normal\ vector\\ (pointing\ in\ the\ right\ direction)\ to\ get\ R'_\parallel \\ |R'_\parallel|(-n) = (-n)\sqrt{1 - |R'_\perp|^2} \\ R'_\parallel=-\sqrt{1 - |R'_\perp|^2}\times n $$ And so we get R' with: $$ R'=R'_\perp+R'_\parallel $$
Cross Product
This
3b1b video
is good. $$ Let\ vector\ X = \begin{bmatrix}x \\ y \\ z\end{bmatrix},\ p = \begin{bmatrix}p_1 \\ p_2 \\ p_3\end{bmatrix},\ u = \begin{bmatrix}u_1 \\ u_2 \\ u_3\end{bmatrix},\ v = \begin{bmatrix}v_1 \\ v_2 \\ v_3\end{bmatrix} $$ The 3D determinant can be derived geometrically much as the 2D determinant can, a proof is not provided here, but in any case can be seen as the magnitude of the matrix, which you can use to 'normalise' the matrix in a sense.
Let's say you're looking for a function which maps 3, 3D vectors to a number. A function which does this would be the determinant of a 3x3 matrix. $$ f\left(\begin{bmatrix} x \\ y \\ z \end{bmatrix}\right) = \det\left(\begin{bmatrix} x & u_1 & v_1 \\ y & u_2 & v_2 \\ z & u_3 & v_3 \end{bmatrix}\right) \\= Volume\ of\ parallelepiped\ defined\ by\ 2\ predefined\ vectors\ and\ 1\ supplied\ vector $$ The determinant is a linear mapping/linear function to some value, and so the function is a covector that can be expressed as a row vector: $$ \begin{bmatrix} p_1 \\ p_2 \\ p_3 \end{bmatrix} \cdot \begin{bmatrix} x \\ y \\ z \end{bmatrix} =\begin{bmatrix} p_1 & p_2 & p_3 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \end{bmatrix} = \det(\begin{bmatrix} x & u_1 & v_1 \\ y & u_2 & v_2 \\ z & u_3 & v_3 \end{bmatrix}) $$ $$ p_1 \cdot x + p_2 \cdot y + p_3 \cdot z = x \cdot (u_2 \cdot v_3 - v_2 \cdot u_3) - u_1\cdot (y\cdot v_3 - v_2 \cdot z) + v_1 \cdot (y \cdot u_3 - u_2 \cdot z) \\ p_1 \cdot x + p_2 \cdot y + p_3 \cdot z = (u_2 \cdot v_3 - u_3 \cdot v_2) \cdot x + (u_3\cdot v_1 - u_1 \cdot v_3) \cdot y + (u_1 \cdot v_2 - u_2 \cdot v_1) \cdot z $$ $$ So, \ by \ equating \ coefficients:\\ \begin{bmatrix} p_1 \\ p_2 \\ p_3 \end{bmatrix} = \begin{bmatrix} u_2 \cdot v_3 - u_3 \cdot v_2 \\ u_3\cdot v_1 - u_1 \cdot v_3 \\ u_1 \cdot v_2 - u_2 \cdot v_1 \end{bmatrix} $$ The volume of a parallelepiped is: $$ Volume\ of\ a\ parallelepiped\ = area\ of\ base \times perpendicuar\ height $$ The projection of a vector
X
onto a vector perpendicular to
u
and
v
, is the perpendicular height of the parallelepiped, and then multiplying that by the area of the parallelogram defined by
u
and
v
, would give the volume of the parallelelpied.
Since we know that the determinant gives the volume, we can interpret it as a volume calculation for that shape.
$$ \det(\begin{bmatrix} x & u_1 & v_1 \\ y & u_2 & v_2 \\ z & u_3 & v_3 \end{bmatrix})\\= (area \ defined\ by\ u\ and \ v) \times (component \ of \ X\ perpendicular\ to\ both\ u\ and\ v) $$ Now we know: - `p ⋅ X` = component of `X` parallel to `p` times the length of `p` - the above is equal to the volume of the parallelepiped (as per the result towards the top of this section) - the height of the parallelepiped is the component of `X` perpendicular to `u` and `v` - the area of the base of the parallelepiped is the area defined by `u` and `v`
The grey vector in the image is the component of `X` parallel to `u` and `v`.
The vector `p` must be: - the height of the parallelepiped (since it's the perpendicular component of X)
And the length: - must encode the area of the parallelogram between `u` and `v` - since that is the only way for
p ⋅ X
to be equal to the determinant of that matrix/volume of the parallelepiped So from that, we have that `p` is the vector which is perpendicular to `u` and `v`.
Since this is a useful result, it is defined as the cross product/scalar product, and written as: $$ u \times v = p \\ \begin{bmatrix}u_1 \\ u_2 \\ u_3\end{bmatrix} \times \begin{bmatrix}v_1 \\ v_2 \\ v_3\end{bmatrix} = \begin{bmatrix} u_2 \cdot v_3 - u_3 \cdot v_2 \\ u_3\cdot v_1 - u_1 \cdot v_3 \\ u_1 \cdot v_2 - u_2 \cdot v_1 \end{bmatrix} $$ Obviously, this also implies that there are cases when the cross product is negative, and to understand which direction the normal would point in before calculation, [use the right hand rule](https://en.wikipedia.org/wiki/Right-hand_rule).
For a look at where the formula for both the dot product and cross product may have first originated from, have a look at [this maths stackexchange answer](https://math.stackexchange.com/questions/62318/origin-of-the-dot-and-cross-product/2491331#2491331). # Row, Column and Null Space - Row space of $A \in \mathbb{R}^{m \times n}$ is the linear combination of the rows of $A$, i.e the span of the rows of A - Column space of $A$ is the span of the columns of $A$ - $dim(rowspace(A)) = rank(A) = dim(colspace(A))$ - $rank(A)+ker(A) = rank(A)+nullity(A)=n$ - If $Ay=0$ has solutions, then $Ax=v$ has free variables, since $A(x+y)=Ax+Ay=v+0=v$, i.e $y$ could be added to $x$ in $Ax=v$ without changing the solution