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

Update documentation #97

Merged
merged 31 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
892e3ed
add docstrings for real and Quaternion
hyrodium Sep 17, 2022
b7118eb
add api.md
hyrodium Sep 17, 2022
32516f4
remove invisible character (U+00ad)
hyrodium Sep 17, 2022
59e006b
add docstrings for conj and imag_part
hyrodium Sep 17, 2022
0933d52
update api.md
hyrodium Sep 17, 2022
86941c0
Update docstring of `imag_part`
hyrodium Sep 19, 2022
20964ce
add docstring of `real(::Type{Quaternion{T}})`
hyrodium Sep 19, 2022
f89702f
add an example `real(::Array{<:Quaternion})`
hyrodium Sep 19, 2022
10ba11d
Update the docstrings of `Quaternion`
hyrodium Sep 19, 2022
1302f65
Merge branch 'master' into documentation
hyrodium Oct 6, 2022
0ba8e28
update README.md
hyrodium Oct 6, 2022
2e02398
update README.md
hyrodium Oct 6, 2022
a425e7a
more specific type in docstring
hyrodium Oct 15, 2022
90c1367
Merge remote-tracking branch 'origin/master' into documentation
hyrodium Oct 15, 2022
58d5778
Add docstring for `Base.real(::AbstractArray{<:Quaternion})`
hyrodium Oct 15, 2022
66acd30
remove duplicated jldoctest for `Base.real`
hyrodium Oct 15, 2022
cffcb62
add docstring for `quat`
hyrodium Oct 15, 2022
362c168
update wording
hyrodium Oct 16, 2022
083ad7b
rename APIs to API
hyrodium Oct 17, 2022
286452c
Fix docstring with plural
hyrodium Oct 17, 2022
aa48327
Use Oxford comma in docstring
hyrodium Oct 17, 2022
fd870d1
add more jidoctests for `quat`
hyrodium Oct 17, 2022
959b0e8
update docstring of `imag_part`
hyrodium Oct 17, 2022
d013c01
update docstring of `imag_part`
hyrodium Oct 17, 2022
584cd6d
update docstring of `imag_part`
hyrodium Oct 17, 2022
a361fb8
update docstring of `real`
hyrodium Oct 17, 2022
df0c10d
update docstring of `extend_analytic`
hyrodium Oct 17, 2022
4ed5156
add depwarn to Quaternion(a::AbstractVector)
hyrodium Oct 17, 2022
c0deff1
add `@test_deprecated` for `quat`
hyrodium Oct 17, 2022
56224b4
add docstring of `slerp`
hyrodium Oct 17, 2022
d385a99
add more `@docs` in api.md
hyrodium Oct 17, 2022
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
56 changes: 3 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,7 @@ A Julia implementation of quaternions.
[![codecov](https://codecov.io/gh/JuliaGeometry/Quaternions.jl/branch/master/graph/badge.svg?token=dJBiR91dCD)](https://codecov.io/gh/JuliaGeometry/Quaternions.jl)

[Quaternions](http://en.wikipedia.org/wiki/Quaternion) are best known for their suitability
as representations of 3D rotational orientation. They can also be viewed as an extension of complex numbers.
as representations of 3D rotational orientation.
They can also be viewed as an extension of complex numbers.

Implemented functions are:
hyrodium marked this conversation as resolved.
Show resolved Hide resolved

+-*/^
real
imag_part (tuple)
conj
abs
abs2
normalize
normalizea (return normalized quaternion and absolute value as a pair)
angleaxis (taken as an orientation, return the angle and axis (3 vector) as a tuple)
angle
axis
sqrt
exp
exp2
exp10
expm1
log2
log10
log1p
sin
cos
tan
asin
acos
atan
sinh
cosh
tanh
asinh
acosh
atanh
csc
sec
cot
acsc
asec
acot
csch
sech
coth
acsch
asech
acoth
sinpi
cospi
sincos
sincospi
slerp
rand
randn
In JuliaGeometry organization, there is also [Octonions.jl](https://github.com/JuliaGeometry/Octonions.jl).
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ makedocs(;
),
pages=[
"Home" => "index.md",
"APIs" => "api.md",
"Examples" => ["examples/dual_quaternions.md"],
],
)
Expand Down
25 changes: 25 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# APIs
hyrodium marked this conversation as resolved.
Show resolved Hide resolved

```@docs
hyrodium marked this conversation as resolved.
Show resolved Hide resolved
Quaternion
```

```@docs
quat
hyrodium marked this conversation as resolved.
Show resolved Hide resolved
```

```@docs
real(::Quaternion)
```

```@docs
imag_part
```

```@docs
conj
```

```@docs
Quaternions.extend_analytic
```
70 changes: 69 additions & 1 deletion src/Quaternion.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""
Quaternion{T<:Real} <: Number

Quaternion number type with real and imaginary part of type `T`.
hyrodium marked this conversation as resolved.
Show resolved Hide resolved

`QuaternionF16`, `QuaternionF32` and `QuaternionF64` are aliases for
hyrodium marked this conversation as resolved.
Show resolved Hide resolved
`Quaternion{Float16}`, `Quaternion{Float32}`, and `Quaternion{Float64}`, respectively.

See also: [`quat`](@ref), [`real`](@ref), [`imag_part`](@ref).
"""
struct Quaternion{T<:Real} <: Number
s::T
v1::T
Expand Down Expand Up @@ -29,14 +39,72 @@ quat(p, v1, v2, v3, n) = Quaternion(p, v1, v2, v3, n)
quat(x) = Quaternion(x)
quat(s, a) = Quaternion(s, a)

"""
real(T::Type)
hyrodium marked this conversation as resolved.
Show resolved Hide resolved

Return the type that represents the real part of a value of type `T`.
e.g: for `T == Quaternion{R}`, returns `R`.
Equivalent to `typeof(real(zero(T)))`.

# Examples
```jldoctest
julia> real(Quaternion{Int})
Int64
```
"""
real(::Type{Quaternion{T}}) where {T} = T

"""
real(q::Quaternion)

Return the real part of the quaternion `q`.

See also: [`imag_part`](@ref), [`quat`](@ref), [`isreal`](@ref).
hyrodium marked this conversation as resolved.
Show resolved Hide resolved

# Examples
```jldoctest
julia> real(quat(1,2,3,4))
1

julia> real([quat(5,6,7,8), 9])
2-element Vector{Int64}:
5
9
```
hyrodium marked this conversation as resolved.
Show resolved Hide resolved
"""
real(q::Quaternion) = q.s

hyrodium marked this conversation as resolved.
Show resolved Hide resolved
"""
imag_part(q::Quaternion{T})
hyrodium marked this conversation as resolved.
Show resolved Hide resolved

Return the imaginary part of the quaternion `q` with type `Tuple{T,T,T}`.
hyrodium marked this conversation as resolved.
Show resolved Hide resolved
Note that this function is different from `Base.imag` which returns `Real`.
hyrodium marked this conversation as resolved.
Show resolved Hide resolved

See also: [`real`](@ref), [`conj`](@ref).

# Examples
```jldoctest
julia> imag_part(Quaternion(1,2,3,4))
(2, 3, 4)
```
"""
imag_part(q::Quaternion) = (q.v1, q.v2, q.v3)

(/)(q::Quaternion, x::Real) = Quaternion(q.s / x, q.v1 / x, q.v2 / x, q.v3 / x)
(*)(q::Quaternion, x::Real) = Quaternion(q.s * x, q.v1 * x, q.v2 * x, q.v3 * x)
(*)(x::Real, q::Quaternion) = q * x

"""
conj(q::Quaternion)

Compute the quaternion conjugate of a quaternion `q`.

# Examples
```jldoctest
julia> conj(Quaternion(1,2,3,4))
Quaternion{Int64}(1, -2, -3, -4, false)
```
"""
conj(q::Quaternion) = Quaternion(q.s, -q.v1, -q.v2, -q.v3, q.norm)
abs(q::Quaternion) = sqrt(abs2(q))
float(q::Quaternion{T}) where T = convert(Quaternion{float(T)}, q)
Expand Down Expand Up @@ -129,7 +197,7 @@ See Theorem 5 of [^Sudbery1970] for details.

[^Sudbery1970]
hyrodium marked this conversation as resolved.
Show resolved Hide resolved
Sudbery (1979). Quaternionic analysis. Mathematical Proceedings of the Cambridge
Philosophical Society,85, pp 199­225
Philosophical Society,85, pp 199225
doi:[10.1017/S030500410005563](https://doi.org/10.1017/S0305004100055638)
"""
function extend_analytic(f, q::Quaternion)
Expand Down