https://github.com/murrellgroup/kabsch.jl
  
  
    Kabsch algorithm for optimally aligning two paired sets of points 
    https://github.com/murrellgroup/kabsch.jl
  
gpu-accelerated julia kabsch rmsd static-arrays
        Last synced: 4 months ago 
        JSON representation
    
Kabsch algorithm for optimally aligning two paired sets of points
- Host: GitHub
 - URL: https://github.com/murrellgroup/kabsch.jl
 - Owner: MurrellGroup
 - License: mit
 - Created: 2025-06-07T21:22:58.000Z (5 months ago)
 - Default Branch: main
 - Last Pushed: 2025-06-14T22:14:31.000Z (5 months ago)
 - Last Synced: 2025-06-16T19:19:41.336Z (5 months ago)
 - Topics: gpu-accelerated, julia, kabsch, rmsd, static-arrays
 - Language: Julia
 - Homepage:
 - Size: 235 KB
 - Stars: 1
 - Watchers: 1
 - Forks: 0
 - Open Issues: 1
 - 
            Metadata Files:
            
- Readme: README.md
 - License: LICENSE
 
 
Awesome Lists containing this project
README
          # Kabsch.jl
[](https://MurrellGroup.github.io/Kabsch.jl/stable/)
[](https://MurrellGroup.github.io/Kabsch.jl/dev/)
[](https://github.com/MurrellGroup/Kabsch.jl/actions/workflows/CI.yml?query=branch%3Amain)
[](https://codecov.io/gh/MurrellGroup/Kabsch.jl)
A Julia implementation of the Kabsch algorithm for finding the optimal rotation between paired sets of points.
## Usage
```julia
using Kabsch, Manifolds
# Generate realistic test data
P = randn(3, 10)
R_true = rand(Rotations(3))  # Random rotation matrix
Q = R_true * centered(P) .+ randn(3)  # Rotate and translate P
# Find optimal alignment
R, P_centroid, Q_centroid = kabsch(P, Q)
Q_aligned = superimposed(Q, P)
# Verify perfect alignment
@assert P ≈ Q_aligned
@assert rmsd(superimposed, Q, P) ≈ 0
```
### Batched Operations
Process multiple alignments simultaneously:
```julia
Ps = randn(3, 50, 8)  # 8 reference point sets
Qs = randn(3, 50, 8)  # 8 point sets to align, uncorrelated for ease of showcase
Rs, P_centroids, Q_centroids = kabsch(Ps, Qs)
Q_aligned_all = superimposed(Qs, Ps)
```
### Extensions
**StaticArrays:** Optimal performance for small point sets
```julia
using StaticArrays
P = @SMatrix randn(3, 5)
Q = @SMatrix randn(3, 5)  # uncorrelated for ease of showcase
R, Pt, Qt = kabsch(P, Q)
```
**CUDA:** GPU acceleration for 3D case
```julia
using CUDA
P_gpu = CUDA.randn(3, 100, 1000)  # 100 batches on GPU
Q_gpu = CUDA.randn(3, 100, 1000)  # uncorrelated for ease of showcase
R_gpu, _, _ = kabsch(P_gpu, Q_gpu)
```
## See also
- [BioStructures.jl](https://github.com/BioJulia/BioStructures.jl) for `rmsd` and `superimpose!` on molecular structures (including residue alignment)