API
Quaternions.Quaternion — Type
Quaternions.quat — Function
quat(w, [x, y, z])Convert real numbers or arrays to quaternion. x, y, z defaults to zero.
Examples
julia> quat(7)
Quaternion{Int64}(7, 0, 0, 0)
julia> quat(1.0, 2, 3, 4)
QuaternionF64(1.0, 2.0, 3.0, 4.0)
julia> quat([1, 2, 3])
3-element Vector{Quaternion{Int64}}:
Quaternion{Int64}(1, 0, 0, 0)
Quaternion{Int64}(2, 0, 0, 0)
Quaternion{Int64}(3, 0, 0, 0)sourceQuaternions.imag_part — Function
Base.round — Method
round(q::Quaternion[, RoundingModeReal, [RoundingModeImaginary]]; kwargs...)
round(q::Quaternion, RoundingModeReal,
RoundingModeImaginary1, RoundingModeImaginary2, RoundingModeImaginary3; kwargs...)Return the nearest integral value of the same type as the quaternion-valued q to q, breaking ties using the specified RoundingModes.
The first RoundingMode is used for rounding the real part while the second is used for rounding the imaginary parts. Alternatively, a RoundingMode may be provided for each part.
The kwargs are the same as those for round(::Real[, RoundingMode]; kwargs...).
Example
julia> round(quat(3.14, 4.5, 8.3, -2.8))
QuaternionF64(3.0, 4.0, 8.0, -3.0)sourceBase.inv — Function
inv(q::Quaternion)Return the multiplicative inverse of q::Quaternion, such that q*inv(q) or inv(q)*q yields one(q) (the multiplicative identity) up to roundoff errors.
Examples
julia> inv(quat(1))
QuaternionF64(1.0, -0.0, -0.0, -0.0)
julia> inv(quat(1, 2, 0, 0))
QuaternionF64(0.2, -0.4, -0.0, -0.0)
julia> inv(quat(2//3))
Quaternion{Rational{Int64}}(3//2, 0//1, 0//1, 0//1)sourceQuaternions.slerp — Function
slerp(qa::Quaternion, qb::Quaternion, t::Real)Spherical linear interpolation (Slerp) between the inputs qa and qb. Since the input is normalized inside the function, the absolute value of the return value will be 1.
Examples
julia> using Quaternions
julia> qa = Quaternion(1,0,0,0)
Quaternion{Int64}(1, 0, 0, 0)
julia> qb = Quaternion(0,1,0,0)
Quaternion{Int64}(0, 1, 0, 0)
julia> slerp(qa, qb, 0.6)
QuaternionF64(0.5877852522924731, 0.8090169943749475, 0.0, 0.0)
julia> ans ≈ Quaternion(cospi(0.3), sinpi(0.3), 0, 0)
truesourceQuaternions.extend_analytic — Function
extend_analytic(f, q::Quaternion)Evaluate the extension of the complex analytic function f to the quaternions at q.
Given $q = s + a u$, where $s$ is the real part, $u$ is a pure unit quaternion, and $a \ge 0$ is the magnitude of the imaginary part of $q$,
\[f(q) = \Re(f(z)) + \Im(f(z)) u,\]
is the extension of f to the quaternions, where $z = s + a i$ is a complex analog to $q$.
See Theorem 5 of [Sudbery1970] for details.
source- Sudbery1970Sudbery (1979). Quaternionic analysis. Mathematical Proceedings of the Cambridge Philosophical Society,85, pp 199225 doi:10.1017/S030500410005563