Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RotationGenerator and its subtypes #203

Merged
merged 29 commits into from
Jan 13, 2022
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
034e2f6
add infinitesimal rotations
hyrodium Nov 20, 2021
0c52741
update log with InfinitesimalRotation
hyrodium Nov 14, 2021
498cb1c
rename log.jl to logexp.jl, and fix tests
hyrodium Nov 20, 2021
b3d2268
update infinitesimal
hyrodium Nov 20, 2021
20a53e0
add tests for infinitesimal rotations
hyrodium Nov 20, 2021
bda9f38
update tests for infinitesimal
hyrodium Nov 20, 2021
f19e191
update src for infinitesimal
hyrodium Nov 20, 2021
6106e07
fix typo
hyrodium Nov 20, 2021
6e0e149
add tests for error
hyrodium Nov 20, 2021
fa141fb
update Base.:-
hyrodium Nov 20, 2021
2c22177
add tests for type promotion
hyrodium Nov 20, 2021
c6bd658
update tests
hyrodium Nov 20, 2021
95bcb18
update Base.ones
hyrodium Nov 20, 2021
500a2d9
update tests
hyrodium Nov 20, 2021
b3aa8c0
update comments
hyrodium Nov 20, 2021
faa2b8a
update export
hyrodium Nov 20, 2021
377294d
fix type parameter in test
hyrodium Nov 20, 2021
173c282
update tests
hyrodium Nov 20, 2021
71de499
add Base.:/(r::InfinitesimalRotation, t::Number)
hyrodium Nov 20, 2021
a859beb
update comments
hyrodium Nov 20, 2021
c6ce5cb
update 2d infinitesimal rotation
hyrodium Nov 20, 2021
af3f7b2
update tests
hyrodium Nov 20, 2021
4faa473
update tests
hyrodium Nov 20, 2021
50e98b3
rename InfinitesimalRotation to RotationGenerator
hyrodium Nov 22, 2021
77b10f1
rename files
hyrodium Nov 22, 2021
aaf529d
add test fot exp(::RotMatrixGenerator)::RotMatrix
hyrodium Nov 22, 2021
c133d83
fix for exp(::RotMatrixGenerator)::RotMatrix
hyrodium Nov 22, 2021
89d6a39
update tests to remove rand method
hyrodium Nov 22, 2021
b55c9ee
remove unnecessary Base.promote_op method
hyrodium Nov 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update infinitesimal
hyrodium committed Nov 20, 2021
commit b3d226879cf1b92702e898eb634217bfa8b27250
26 changes: 13 additions & 13 deletions src/infinitesimal.jl
Original file line number Diff line number Diff line change
@@ -14,13 +14,16 @@ Base.transpose(r::InfinitesimalRotation{N,T}) where {N,T<:Real} = -r

# Generate identity-matrix with SMatrix
# Note that zeros(InfinitesimalRotation3,dims...) is not Array{<:InfinitesimalRotation} but Array{<:StaticMatrix{3,3}}
Base.one(::InfinitesimalRotation{N,T}) where {N,T} = @SMatrix ones(T,N,N)
Base.one(::InfinitesimalRotation{N,T}) where {N,T} = one(SMatrix{N,N,T})
Base.one(::Type{InfinitesimalRotation}) = error("The dimension of rotation is not specified.")
Base.one(::Type{<:InfinitesimalRotation{N}}) where N = @SMatrix ones(N,N)
Base.one(::Type{<:InfinitesimalRotation{N,T}}) where {N,T} = @SMatrix ones(T,N,N)
Base.one(::Type{<:InfinitesimalRotation{N}}) where N = one(SMatrix{N,N})
Base.one(::Type{<:InfinitesimalRotation{N,T}}) where {N,T} = one(SMatrix{N,N,T})
Base.ones(::Type{R}) where {R<:InfinitesimalRotation} = ones(R, ()) # avoid StaticArray constructor
Base.ones(::Type{R}, dims::Base.DimOrInd...) where {R<:InfinitesimalRotation} = ones(typeof(one(R)),dims...)
Base.ones(::Type{R}, dims::NTuple{N, Integer}) where {R<:InfinitesimalRotation, N} = ones(typeof(one(R)),dims)
# Base.ones(::Type{R}, dims::Base.DimOrInd...) where {R<:InfinitesimalRotation} = ones(typeof(one(R)),dims...)
# Base.ones(::Type{R}, dims::NTuple{N, Integer}) where {R<:InfinitesimalRotation, N} = ones(typeof(one(R)),dims)

# Generate identity rotation matrix
Base.zero(r::InfinitesimalRotation) = zero(typeof(r))

# `convert` goes through the constructors, similar to e.g. `Number`
Base.convert(::Type{R}, rot::InfinitesimalRotation{N}) where {N,R<:InfinitesimalRotation{N}} = R(rot)
@@ -85,8 +88,6 @@ end
InfinitesimalRotMatrix(@SMatrix T[zero(θ) -θ; θ zero(θ)])
end

Base.one(::Type{R}) where {N,R<:InfinitesimalRotMatrix{N}} = R(I)

# A rotation is more-or-less defined as being an orthogonal (or unitary) matrix
Base.:-(r::InfinitesimalRotMatrix) = InfinitesimalRotMatrix(-r.mat)

@@ -98,10 +99,9 @@ Base.:-(r::InfinitesimalRotMatrix) = InfinitesimalRotMatrix(-r.mat)

# Special case multiplication of 2×2 rotation matrices: speedup using skew-symmetricity
@inline function Base.:+(r1::InfinitesimalRotMatrix{2}, r2::InfinitesimalRotMatrix{2})
s12 = r1[2,1]+r2[2,1]
s = @SMatrix [0 s12 -s31
-s12 0 s23
s31 -s23 0]
v = r1[2,1]+r2[2,1]
s = @SMatrix [0 -v
v 0]
return InfinitesimalRotMatrix(s)
end

@@ -138,7 +138,7 @@ end
@inline InfinitesimalAngle2d(r::InfinitesimalRotation{2}) = InfinitesimalAngle2d(r[2,1])
@inline InfinitesimalAngle2d{T}(r::InfinitesimalRotation{2}) where {T} = InfinitesimalAngle2d{T}(r[2,1])

@inline Base.zero(::Type{A}) where {A<: InfinitesimalAngle2d} = A(0)
@inline Base.zero(::Type{A}) where {A<: InfinitesimalAngle2d} = A(0.0)

@inline Base.:+(r1::InfinitesimalAngle2d, r2::InfinitesimalAngle2d) = InfinitesimalAngle2d(r1.v + r2.v)
@inline Base.:-(r1::InfinitesimalAngle2d, r2::InfinitesimalAngle2d) = InfinitesimalAngle2d(r1.v - r2.v)
@@ -187,7 +187,7 @@ end
@inline InfinitesimalRotationVec(r::InfinitesimalRotation{3}) = InfinitesimalRotationVec(r[6], r[7], r[2])
@inline InfinitesimalRotationVec{T}(r::InfinitesimalRotation{3}) where {T} = InfinitesimalRotationVec{T}(r[6], r[7], r[x])

@inline Base.zero(::Type{A}) where {A<: InfinitesimalRotationVec} = A(0)
@inline Base.zero(::Type{R}) where {R<: InfinitesimalRotationVec} = R(0.0,0.0,0.0)

@inline Base.:+(r1::InfinitesimalRotationVec, r2::InfinitesimalRotationVec) = InfinitesimalRotationVec(r1.x + r2.x, r1.y + r2.y, r1.z + r2.z)
@inline Base.:-(r1::InfinitesimalRotationVec, r2::InfinitesimalRotationVec) = InfinitesimalRotationVec(r1.x - r2.x, r1.y - r2.y, r1.z - r2.z)