-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
We now have two types for 2D rotations:
RotMatrix{2}stores four real values as a matrixAngle2dstores one real value as a rotation angle
However, a 2D rotation can be parametrized with two real values
This rotation is the same as a rotation by a complex number
struct ComplexRotation{T} <: Rotation{2,T}
c::Complex{T}
endThis is sometimes useful when we need to generate a rotation from 2D vectors.
See rotation_between for example.
Rotations.jl/src/rotation_between.jl
Lines 9 to 15 in f00b07d
| function rotation_between(u::StaticVector{2}, v::StaticVector{2}) | |
| c = complex(v[1], v[2]) / complex(u[1], u[2]) | |
| iszero(c) && throw(ArgumentError("Input vectors must be nonzero and finite.")) | |
| isfinite(c) || throw(ArgumentError("Input vectors must be nonzero and finite.")) | |
| theta = Base.angle(c) | |
| return Angle2d(theta) | |
| end |
Metadata
Metadata
Assignees
Labels
No labels