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

What is n::Bool in the Quaternion constructor? #36

Closed
homocomputeris opened this issue Nov 7, 2019 · 6 comments
Closed

What is n::Bool in the Quaternion constructor? #36

homocomputeris opened this issue Nov 7, 2019 · 6 comments

Comments

@homocomputeris
Copy link

What is n::Bool=false in the Quaternion constructor? What does it represent?

@goretkin
Copy link

The Quaternion type is defined here:

struct Quaternion{T<:Real} <: Number
s::T
v1::T
v2::T
v3::T
norm::Bool
end

It includes a field to indicate whether the quaternion has unit length. The killer app for quaternions is that a unit-length quaternion can represent a rotations in 3D. You might think of it as a way to cache the computation of computing the length.

FYI, not many libraries implement quaternions in this way from what I see.

@homocomputeris
Copy link
Author

The problem with this implementation is (or was, at least) that one could create a non-unit quaternion and set norm=True, basically making the argument useless.

@goretkin
Copy link

The point is to avoid unnecessary computation, so I don't see a way around that problem.

@homocomputeris
Copy link
Author

The constructor should check it a passed quadruple can represent a unit quaternion.

@goretkin
Copy link

That "check" is exactly the unnecessary computation I mean. There are cases where you know that the quadruple has unit length. For example, if you wanted to ignore floating point issues, you might want to assert that multiplying two unit-length quaternions produces a unit-length quaternion.

@hyrodium
Copy link
Collaborator

hyrodium commented Apr 9, 2022

The .norm field will be removed in #75, and it will not be documented.

@hyrodium hyrodium closed this as completed Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants