diff --git a/src/linear_algebra.jl b/src/linear_algebra_basic.jl similarity index 94% rename from src/linear_algebra.jl rename to src/linear_algebra_basic.jl index 00eb348..e767bd5 100644 --- a/src/linear_algebra.jl +++ b/src/linear_algebra_basic.jl @@ -81,11 +81,11 @@ end """ function reflection(v::Vector, w::Vector) -> Vector -The projection P from 'w' onto 'v' is the midpoint of the reflection of w around v +The midpoint of the segment from `v` to the reflection of `v` is the projection P from 'v' to the line along 'w' """ -function reflection(v::Vector, w::Vector) - P = orthproj(v,w) - (2 * P ) - X +function reflection(v::Vector,w::Vector) + P = orthproj(w,v) + (2 * P ) - w end """ @@ -280,12 +280,3 @@ function intersection_2_implicit_lines(a₁::Number, b₁::Number, c₁::Number, A\b end -""" - function matrix_orthproj_basis(v::Vector) -> Matrix -Compute matrix of orthogonal projection of basis vectors on line along vector v -""" -function matrix_orthproj_basis(v::Vector) - e₁ =[1,0] - e₂ = [0,1] - [permutedims(orthproj(v, e₁)); permutedims(orthproj(v, e₂))] -end diff --git a/src/linear_algebra_transform.jl b/src/linear_algebra_transform.jl new file mode 100644 index 0000000..6ee1fc0 --- /dev/null +++ b/src/linear_algebra_transform.jl @@ -0,0 +1,22 @@ +using Symbolics +include("./linear_algebra_basic.jl") + +@variables u v +""" + function projection_matrix_symbolic() -> Matrix +Create symbolic matrix for projection on [u, v] using E₁ = [1,0] and E₂ =[0,1] to get first and second row +""" +function projection_matrix_symbolic() + [orthproj([u, v], [1, 0])[1] orthproj([u, v], [0, 1])[1]; orthproj([u, v], [1, 0])[2] orthproj([u, v], [0, 1])[2]] +end + +function projection_matrix_symbolic_polar() + simplify.(substitute.(projection_matrix_symbolic(),(Dict(u => cos(θ), v => sin(θ)),))) +end +""" + function projection_matrix(x::Vector) -> Matrix +value of Matrix with an actual x +""" +function projection_matrix(x::Vector) + Symbolics.value.(substitute.(projection_matrix_symbolic(), (Dict(u =>x[1], v=> x[2]), ))) +end