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

Quaternion Math #35

Open
pashabou opened this issue Nov 7, 2019 · 4 comments
Open

Quaternion Math #35

pashabou opened this issue Nov 7, 2019 · 4 comments
Labels
new module Proposals for new modules

Comments

@pashabou
Copy link

pashabou commented Nov 7, 2019

Since the Numerics modules cover complex numbers and operations, and you mentioned here (#6) that ShapedArrays are within the scope of the project, would quaternion math and possibly other algebras fall under the scope of Swift Numerics as well?

Use cases include everywhere 3D rotation is used, from games and visualization to simulation and control systems. A well-tested and well-documented implementation would be a big boon for a new math library. Some quick googling shows this is not in the C++ STL or a standard part of NumPy, but it is a standard part of MATLAB and part of Accelerate (maybe better suited as part of an update/rewrite of Accelerate?).

@stephentyrone stephentyrone added the new module Proposals for new modules label Nov 8, 2019
@stephentyrone
Copy link
Member

Hi @pashabou -- quaternions are definitely in-scope, this is a reasonable suggestion.

A couple quick notes:

  • a quaternion implementation should wrap the SIMD4 type from the Standard Library
  • we'd probably also want to add an explicit 3d vector type, since quaternions are mostly useful as an abstraction for representing rotations and dilations of 3d vector spaces.
  • there's an interesting discussion about whether or not it's worth having a unit-quaternion type
  • there's an interesting discussion about whether to talk about quaternions or rotations or both (unit quaternions are a double-cover of rotations, so the two things have different notions of equality).

@markuswntr
Copy link
Contributor

Hi @pashabou and @stephentyrone,

I just raised a PR with an implementation sketch for Quaternions.
I hope it is okay for both of you that I linked the PR against this issue (altough I did not open it).

While the PR already lists all the implementation details, I would like to mention, that I am really liking the implementation of the Complex type and I tried to align Quaternion as much as I could (I even re-used a lot of the comments - sorry).
As both may have similar use cases, I found it reasonable to align them as closly as possible.

I have stripped most of the functionality from my initial implementation sketch down to simply having a PR with only the Quaternion type, relevant properties and its most basic arithmetic. It does not define rotations or vector types. I think it will focus the discussion more on the quaternion definition itself and once we have a consent, to iterate upon it. Though, I intent to provide additional functionality (later).

@stephentyrone
Copy link
Member

@markuswntr Thanks!

As a heads-up, I'm a little bit swamped for the next few days, but I'll give your PR a quick skim, then provide more detailed feedback sometime next week.

@markuswntr
Copy link
Contributor

Hi @stephentyrone!

Thanks for the heads-up. There is no hurry.
And thank you very much for the feedback you already provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new module Proposals for new modules
Projects
None yet
Development

No branches or pull requests

3 participants