Skip to content

Commit

Permalink
some cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
zoemcc committed Jul 14, 2023
1 parent aa962b6 commit 68b430c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
9 changes: 1 addition & 8 deletions src/motor3D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Base.:(-)(a::Motor3D, b::Motor3D) = Motor3D(internal_vec(a) .- internal_vec(b))
#⋅(a::Motor3D, b::Motor3D) = internal_vec(a) ⋅ internal_vec(b)
#dot(a::Motor3D, b::Motor3D) = a ⋅ b

function Base.:(*)(a::Motor3D, b::Motor3D)
function Base.:(*)(a::Motor3D, b::Motor3D) # dual quernion geometric product
Motor3D(
a[4] * b[1] + a[1] * b[4] + a[2] * b[3] - a[3] * b[2],
a[4] * b[2] + a[2] * b[4] + a[3] * b[1] - a[1] * b[3],
Expand All @@ -44,13 +44,6 @@ function Base.:(*)(a::Motor3D, b::Motor3D)
a[8] * b[4] - a[5] * b[1] - a[6] * b[2] - a[7] * b[3] + a[4] * b[8] - a[1] * b[5] - a[2] * b[6] - a[3] * b[7]
)
end
#=
old
a[8] * b[3] + a[5] * b[2] - a[6] * b[1] + a[7] * b[4] + b[8] * a[3] - b[5] * a[2] + b[6] * a[1] + b[7] * a[4],
a[8] * b[1] + a[5] * b[4] + a[6] * b[3] - a[7] * b[2] + b[8] * a[1] + b[5] * a[4] - b[6] * a[3] + b[7] * a[2],
a[8] * b[2] - a[5] * b[3] + a[6] * b[4] + a[7] * b[1] + b[8] * a[2] + b[5] * a[3] + b[6] * a[4] - b[7] * a[1],
a[8] * b[4] - a[5] * b[1] - a[6] * b[2] - a[7] * b[3] + b[8] * a[4] - b[5] * a[1] - b[6] * a[2] - b[7] * a[3]
=#

identity_motor() = Motor3D(0, 0, 0, 1, 0, 0, 0, 0)

Expand Down
10 changes: 5 additions & 5 deletions src/vector4D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ end

internal_vec(v::Vector4D) = v.vec

get_x(v::Vector4D) = internal_vec(v)[1]
get_y(v::Vector4D) = internal_vec(v)[2]
get_z(v::Vector4D) = internal_vec(v)[3]
get_w(v::Vector4D) = internal_vec(v)[4]
get_x(v::Vector4D) = v[1]
get_y(v::Vector4D) = v[2]
get_z(v::Vector4D) = v[3]
get_w(v::Vector4D) = v[4]

Vector4D(el::AbstractPGA3DElement{T}) where {T<:Real} = Base.convert(Vector4D{T}, el)

Expand All @@ -32,7 +32,7 @@ dot(a::Vector4D, b::Vector4D) = a ⋅ b

Vector4D(el::AbstractPGA3DElement{T}) where {T<:Real} = convert(Vector4D{T}, el)

bulk_norm(v::Vector4D) = norm((internal_vec(v)[1:3]))
bulk_norm(v::Vector4D) = norm(SA[v[1], v[2], v[3]])
weight_norm(v::Vector4D) = abs(get_w(v))
unitize(v::Vector4D) = Vector4D(internal_vec(v) .* (1 / get_w(v)))

Expand Down

0 comments on commit 68b430c

Please sign in to comment.