JuliaGeometry / Quaternions.jl

A Julia implementation of quaternions
https://juliageometry.github.io/Quaternions.jl
MIT License
116 stars 37 forks source link

`quat([1,2,3,4])` should return `Vector{Quaternion{Int}}` #94

Closed hyrodium closed 1 year ago

hyrodium commented 2 years ago

The function quat should be similar to complex, but the behavior is different.

julia> complex(1)
1 + 0im

julia> quat(1)
Quaternion{Int64}(1, 0, 0, 0, true)

julia> complex([1,2,3,4])
4-element Vector{Complex{Int64}}:
 1 + 0im
 2 + 0im
 3 + 0im
 4 + 0im

julia> quat([1,2,3,4])
Quaternion{Int64}(0, 1, 2, 3, false)

I think quat([1,2,3,4]) should be [Quaternion{Int64}(1,0,0,0), Quaternion{Int64}(2,0,0,0), Quaternion{Int64}(3,0,0,0), Quaternion{Int64}(4,0,0,0)].

hyrodium commented 2 years ago

Btw, quat should be renamed to quaternion just like complex vs Complex?

sethaxen commented 1 year ago

I agree that quat(some_array) should "quaternionify" the array elements by analogy to complex. complex and Complex differ in that complex complexifies the inputs, while Complex is a constructor, and I think we want the same relationship between quat and Quaternion.

Btw, quat should be renamed to quaternion just like complex vs Complex?

Hmm, maybe, for consistency. Although, quat is a useful abbrevation and is likely to be used in code, so I'm inclined to keep it.