-
Notifications
You must be signed in to change notification settings - Fork 13
/
diagonal_zooms.Rmd
82 lines (73 loc) · 1.22 KB
/
diagonal_zooms.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
jupyter:
jupytext:
text_representation:
extension: .Rmd
format_name: rmarkdown
format_version: '1.2'
jupytext_version: 1.11.5
kernelspec:
display_name: Python 3 (ipykernel)
language: python
name: python3
---
# Encoding zooms (scaling) with a diagonal matrix
If I want to express the fact that I am expanding or contracting a coordinate
along the x axis, then I multiply the x coordinate by some scalar $p$:
$$
\begin{bmatrix}
x'\\
y'\\
z'\\
\end{bmatrix} =
\begin{bmatrix}
p x\\
y\\
z\\
\end{bmatrix}
$$
In general if I want to scale by $p$ in $x$, $q$ in
$y$ and $r$ in $z$, then I could multiply each coordinate by
the respective scaling:
$$
\begin{bmatrix}
x'\\
y'\\
z'\\
\end{bmatrix} =
\begin{bmatrix}
p x\\
q y\\
r z\\
\end{bmatrix}
$$
We can do the same thing by multiplying the coordinate by a matrix with the
scaling factors on the diagonal:
$$
\begin{bmatrix}
x'\\
y'\\
z'\\
\end{bmatrix} =
\begin{bmatrix}
p x\\
q y\\
r z\\
\end{bmatrix} =
\begin{bmatrix}
p & 0 & 0 \\
0 & q & 0 \\
0 & 0 & r \\
\end{bmatrix}
\begin{bmatrix}
x\\
y\\
z\\
\end{bmatrix}
$$
You can make these zooming matrices with np.diag:
```{python}
import numpy as np
zoom_mat = np.diag([3, 4, 5])
zoom_mat
```