Skip to content

Commit

Permalink
Update rotational_utils.jl
Browse files Browse the repository at this point in the history
Change back to Lukas' implementation so that we don't use fill, which would create an array on CPU.
  • Loading branch information
AntonOresten authored May 23, 2024
1 parent 677d683 commit 7ffebf7
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/rotational_utils.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# from AF2 supplementary: Algorithm 23 Backbone update
"""
Takes a 3xN matrix of imaginary quaternion components and returns a 4xN matrix of unit quaternions.
Takes a 3xN matrix of imaginary quaternion components, `bcd`, sets the real part to `a`, and normalizes to unit quaternions.
"""
function bcds2quats(bcd::AbstractMatrix{T}) where T <: Real
quats = vcat(ones(T, 1, size(bcd, 2)), bcd)
norms = sqrt.(one(T) .+ sum(abs2, bcd, dims=1))
return quats ./ norms
function bcd_to_quat(bcd::AbstractMatrix{T}, a::T=T(1)) where T <: Real
norms = sqrt.(a .+ sum(abs2, bcd, dims=1))
return vcat(a ./ norms, bcd ./ norms)
end

"""
Expand Down

0 comments on commit 7ffebf7

Please sign in to comment.