|
1 | 1 |
|
| 2 | +@doc raw""" |
| 3 | + $SIGNATURES |
| 4 | +
|
| 5 | +Transform and put 2D pointcloud as [x,y] coordinates of a-frame into `aP_dest`, by transforming |
| 6 | +incoming b-frame points `bP_src` as [x,y] coords via the transform `aTb` describing the b-to-a (aka a-in-b) |
| 7 | +relation. Return the vector of points `aP_dest`. |
| 8 | +
|
| 9 | +````math |
| 10 | +{}^a \begin{bmatrix} x, y \end{bmatrix} = {}^a_b \mathbf{T} \, {}^b \begin{bmatrix} x, y \end{bmatrix} |
| 11 | +```` |
| 12 | +
|
| 13 | +DevNotes |
| 14 | +- Consolidate functionality with [`_FastTransform3D`](@ref) |
| 15 | +
|
| 16 | +""" |
| 17 | +function _transformPointCloud!( |
| 18 | + # manifold |
| 19 | + M::Union{<:typeof(SpecialEuclidean(2)),<:typeof(SpecialEuclidean(3))}, |
| 20 | + # destination points |
| 21 | + aP_dest::AbstractVector, |
| 22 | + # source points |
| 23 | + bP_src::AbstractVector, |
| 24 | + # transform coordinates |
| 25 | + aCb::AbstractVector{<:Real}; |
| 26 | + # base point on manifold about which to do the transform |
| 27 | + e0::ArrayPartition = getPointIdentity(M), |
| 28 | + backward::Bool=false |
| 29 | +) |
| 30 | + # |
| 31 | + |
| 32 | + aPb = retract(M, e0, hat(M, e0, aCb)) |
| 33 | + aPb = backward ? inv(M,aPb) : aPb |
| 34 | + # can do 2d or 3d |
| 35 | + aTb = _FastTransform3D(M,aPb) |
| 36 | + aP_dest .= aTb.(bP_src) |
| 37 | + |
| 38 | + aP_dest |
| 39 | +end |
| 40 | + |
| 41 | +function _transformPointCloud( |
| 42 | + # manifold |
| 43 | + M::Union{<:typeof(SpecialEuclidean(2)),<:typeof(SpecialEuclidean(3))}, |
| 44 | + # source points |
| 45 | + bP_src::AbstractVector, |
| 46 | + # transform coordinates |
| 47 | + aCb::AbstractVector{<:Real}; |
| 48 | + kw... |
| 49 | +) |
| 50 | + # |
| 51 | + #dest points |
| 52 | + aP_dest = Vector{MVector{length(bP_src[1]),Float64}}(undef,length(bP_src)) |
| 53 | + _transformPointCloud!(M, aP_dest, bP_src, aCb; kw...) |
| 54 | +end |
| 55 | + |
| 56 | + |
2 | 57 |
|
3 | 58 | ## ============================================================ |
4 | 59 | ## Consolidated rigid transform standardized against Manifolds.jl |
|
8 | 63 | # Works for transform of both 2D and 3D point clouds |
9 | 64 | # FIXME, to optimize, this function will likely be slow |
10 | 65 | # TODO, consolidate with transformPointcloud(::ScatterAlign,..) function |
11 | | -function Manifolds.apply( M_::Union{<:typeof(SpecialEuclidean(2)),<:typeof(SpecialEuclidean(3))}, |
12 | | - rPp::Manifolds.ArrayPartition, |
13 | | - pc::PointCloud{T} ) where T |
| 66 | +function Manifolds.apply( |
| 67 | + M_::Union{<:typeof(SpecialEuclidean(2)),<:typeof(SpecialEuclidean(3))}, |
| 68 | + rPp::Manifolds.ArrayPartition, |
| 69 | + pc::PointCloud{T} |
| 70 | +) where T |
14 | 71 | # |
15 | 72 |
|
16 | 73 | # allocate destination |
|
0 commit comments