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

How to use quaternion / versor algebra #700

Open
Selorax opened this issue Aug 29, 2024 · 4 comments
Open

How to use quaternion / versor algebra #700

Selorax opened this issue Aug 29, 2024 · 4 comments

Comments

@Selorax
Copy link

Selorax commented Aug 29, 2024

I wanted to multiply two quaternions, however qalc seem to produce this kind of output:

> (1+2i+3j+4k)

  error: Trailing characters "j" (not a valid variable/function/unit) in number "3j" were ignored.
  1 + (2 × i) + 3 + (4 × 1000) = 4004 + 2i

So either I am using wrong syntax or quaternions are not implemented. If they are not implemented, then they probably should be in some way. Search in issues and manual index by keywords versor and quaternion produced no results.

@hanna-kn
Copy link
Contributor

There is no support for quaternions in libqalculate.

@Selorax
Copy link
Author

Selorax commented Aug 30, 2024

@hanna-kn, is it planned to be added?

@hanna-kn
Copy link
Contributor

@hanna-kn, is it planned to be added?

I've not considered it before.

It seems as if it should be relatively easy to add support for quaternions in specific functions, with 4-dimensional vectors as arguments. E.g. 1+2i+3j+4k would be represented as (1, 2, 3, 4) (or [1 2 3 4]) and multiplied using a function perhaps named qmultiply.

Adding quaternion as a separate data class, or as an extension to complex numbers, with support for regular operators and functions, would likely be considerably more complicated and require extensive changes to existing code.

@Selorax
Copy link
Author

Selorax commented Sep 3, 2024

It is up to you, then, how and whether to implement it at all. Of course if quaternions are implemented at all, there should be functions for all arithmetic operations and other things commonly done with them, not just multiplication. Also quaternion multiplication is not commutative, so perhaps notation like (1+2i+3j+4k)*(2+3i+4j+5k) will create additional problems because it's not the same as (2+3i+4j+5k)*(1+2i+3j+4k), unlike complex and real numbers.

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

No branches or pull requests

2 participants