Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 628e98b
Author: Aron T <[email protected]>
Date:   Fri Oct 11 12:16:19 2024 +0300

    add reflection matrix

commit c47ab36
Author: Aron T <[email protected]>
Date:   Thu Oct 3 17:33:56 2024 +0300

    ritation matrix

commit af9b40b
Author: Aron T <[email protected]>
Date:   Tue Oct 1 22:35:30 2024 +0300

    typo
  • Loading branch information
AronT-TLV committed Oct 11, 2024
1 parent afc9c1a commit 47ac3eb
Show file tree
Hide file tree
Showing 4 changed files with 309 additions and 31 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.codeLensFontFamily": "Fira Code",
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true
}
244 changes: 219 additions & 25 deletions notebooks/Linear_Algebra_Basics.ipynb → notebooks/Linear_Algebra.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"intersection_2_implicit_lines"
"rotation_matrix_ns"
]
},
"metadata": {},
Expand All @@ -19,7 +19,7 @@
"using Plots\n",
"using LinearAlgebra\n",
"using Symbolics\n",
"include(\"/Users/aron/Code/Study/Julia/Math/Linear_Algebra//src/linear_algebra.jl\")"
"include(\"/Users/aron/Code/Study/Julia/Math/Linear_Algebra/src/linear_algebra_transform.jl\")"
]
},
{
Expand All @@ -31,7 +31,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand All @@ -54,7 +54,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand All @@ -77,7 +77,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -112,7 +112,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -147,7 +147,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -182,7 +182,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -217,7 +217,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -253,7 +253,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -297,7 +297,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 11,
"metadata": {},
"outputs": [
{
Expand All @@ -316,19 +316,26 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$$ \\begin{equation}\n",
"a t x + b t y\n",
"\\left[\n",
"\\begin{array}{c}\n",
"a t x + b t y \\\\\n",
"c t x + d t y \\\\\n",
"\\end{array}\n",
"\\right]\n",
"\\end{equation}\n",
" $$"
],
"text/plain": [
"a*t*x + b*t*y"
"2-element Vector{Num}:\n",
" a*t*x + b*t*y\n",
" c*t*x + d*t*y"
]
},
"metadata": {},
Expand All @@ -342,7 +349,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 13,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -381,7 +388,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 14,
"metadata": {},
"outputs": [
{
Expand All @@ -407,35 +414,222 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$$ \\begin{equation}\n",
"\\left[\n",
"\\begin{array}{cc}\n",
"\\frac{u^{2}}{u^{2} + v^{2}} & \\frac{u v}{u^{2} + v^{2}} \\\\\n",
"\\frac{u v}{u^{2} + v^{2}} & \\frac{v^{2}}{u^{2} + v^{2}} \\\\\n",
"\\end{array}\n",
"\\right]\n",
"\\end{equation}\n",
" $$"
],
"text/plain": [
"2×2 Matrix{Num}:\n",
" (u^2) / (u^2 + v^2) (u*v) / (u^2 + v^2)\n",
" (u*v) / (u^2 + v^2) (v^2) / (u^2 + v^2)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"@variables u v\n",
"x = [u, v]\n",
"e₁ = [1, 0]\n",
"e₂ = [0, 1]\n",
"P = [permutedims(orthproj(x, e₁)); permutedims(orthproj(x, e₂))]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Rotation of 45 degrees around x axis"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2×2 Matrix{Float64}:\n",
" 0.137931 0.344828\n",
" 0.344828 0.862069"
" 0.707107 -0.707107\n",
" 0.707107 0.707107"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"v = [2, 5]\n",
"e₁ = [1, 0]\n",
"e₂ = [0, 1]\n",
"P = [permutedims(orthproj(v, e₁)); permutedims(orthproj(v, e₂))]"
"x = [1, 0]\n",
"R = [rotation(45, e₁) rotation(45, e₂)]\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$$ \\begin{equation}\n",
"\\left[\n",
"\\begin{array}{cc}\n",
"\\cos\\left( \\theta \\right) & - \\sin\\left( \\theta \\right) \\\\\n",
"\\sin\\left( \\theta \\right) & \\cos\\left( \\theta \\right) \\\\\n",
"\\end{array}\n",
"\\right]\n",
"\\end{equation}\n",
" $$"
],
"text/plain": [
"2×2 Matrix{Num}:\n",
" cos(θ) -sin(θ)\n",
" sin(θ) cos(θ)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"rotation_matrix_symbolic()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Rotation matrix rotates vector by θ degrees"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"2×2 Matrix{Float64}:\n",
" 0.707107 -0.707107\n",
" 0.707107 0.707107"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"R = rotation_matrix(45)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2-element Vector{Float64}:\n",
" 0.7071067811865476\n",
" 0.7071067811865475"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"R * [1, 0]"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2×2 Matrix{Float64}:\n",
" 0.0 -1.0\n",
" 1.0 0.0"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"R = round.(rotation_matrix(90))\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If rotate x-axis by 90 degrees we get to y-axis"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2-element Vector{Float64}:\n",
" 0.0\n",
" 1.0"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"R * [1, 0]"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2-element Vector{Float64}:\n",
" 0.0\n",
" 5.0"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"v = (cos(θ), sin(θ))"
"R * [5, 0]"
]
}
],
Expand Down
Loading

0 comments on commit 47ac3eb

Please sign in to comment.