C/C++ 中的四元数库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/508370/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 15:43:34  来源:igfitidea点击:

quaternion libraries in C/C++

c++mathquaternions

提问by cbrulak

Any good libraries for quaternioncalculations in C/C++ ?

在 C/C++ 中用于四元数计算的任何好的库?

Side note: any good tutorials/examples? I've google it and been to the first few pages but maybe you have have some demos/labs from compsci or math courses you could/would share?

旁注:有什么好的教程/例子吗?我已经在谷歌上搜索并浏览了前几页,但也许你有一些来自 compsci 或数学课程的演示/实验室,你可以/愿意分享?

Thanks

谢谢

采纳答案by Jeff M

I'm a fan of the Irrlicht quaternion class. It is zlib licensed and is fairly easy to extract from Irrlicht:

我是 Irrlicht 四元数类的粉丝。它是 zlib 许可的,并且很容易从 Irrlicht 中提取:

回答by Anonymous

You could try with Boost - usually good place to start with. They have a dedicated sublibraryfor that.

您可以尝试使用 Boost - 通常是开始的好地方。他们有一个专门的子库

As for the examples look at the documentation and the unit tests that come along with Boost.

至于示例,请查看 Boost 附带的文档和单元测试。

回答by DarenW

There's Eigen, a templated library of math and geometry stuff used in Blender and by KDE programs, which has a slick Quaternion class defined in a single .h file.

有 Eigen,一个在 Blender 和 KDE 程序中使用的数学和几何内容的模板库,它在单个 .h 文件中定义了一个漂亮的 Quaternion 类。

Info at http://eigen.tuxfamily.org/index.php?title=Main_Pageand http://www.ohloh.net/p/5393

信息在http://eigen.tuxfamily.org/index.php?title=Main_Pagehttp://www.ohloh.net/p/5393

回答by SuperElectric

If you decide to roll your own, or actually want to understand the math behind the code (useful for debugging), I highly recommend Martin Baker's website. It looks primitive, but the explanations are thorough and easy to follow, and he also provides code in places.

如果您决定自己动手,或者实际上想了解代码背后的数学原理(对调试很有用),我强烈推荐Martin Baker 的网站。看起来很原始,但解释很透彻,很容易理解,而且他还提供了一些地方的代码。

回答by ephemient

DirectX has its own quaternion functions, as do several other 3D libraries.

DirectX 有自己的四元数函数,其他几个 3D 库也是如此。

In my opinion, the best way to learn how quaternions work is to plow through the math yourself. The Wikipedia page on quaternionsand conversioncontain all the formulas you need. I wrote my own quaternion library from that :) (It's in Haskell, so I won't bother to post it.)

在我看来,了解四元数如何工作的最好方法是自己研究数学。关于四元数转换的维基百科页面包含您需要的所有公式。我从中编写了我自己的四元数库:)(它在 Haskell 中,所以我不会费心发布它。)

回答by Sam

For documentation on quaternions, check out 3D graphics text books. They are simply matrices that produce the effect of 3D rotation using multiplication instead of computationally expensive trigonometry.

有关四元数的文档,请查看 3D 图形教科书。它们只是使用乘法而不是计算量大的三角函数产生 3D 旋转效果的简单矩阵。

回答by Jav_Rock

This web, euclideanspace, is very important if you are working with quaternions. It has all arithmetic step by step, equivalences, simplifications, code samples in different languages. I made most of my functions on my own following this page. I prefer that than downoading a library. Functions are easy to program and you learn on the way.

如果您正在使用四元数,这个网络euclideanspace非常重要。它具有所有算术步骤、等价、简化、不同语言的代码示例。在此页面之后,我自己制作了大部分功能。我更喜欢这样而不是下载图书馆。函数易于编程,您可以在途中学习。

As an example I suggest you to check this c++ function about a quaternion multiplication: Efficient C++ quaternion multiplication using cv::Mat

作为一个例子,我建议你检查这个关于四元数乘法的 C++ 函数: Efficient C++ quaternion multiplication using cv::Mat

回答by robswain

There is graphenewhich is a simple C/GObject library with SIMD optimisations for various vector, matrix, quaternion, etc calculations that are common in 3D graphics.

石墨烯是一个简单的C / GObject的库的优化SIMD各种向量,矩阵,四元数等的计算是在3D图形常见。