TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Let's remove Quaternions from every 3D Engine (2018)

145 点作者 hrldcpr超过 3 年前

12 条评论

ajkjk超过 3 年前
100% agree that bivectors are an easier to way to think about quaternions with less magical hand-waving. However, I have an opinion that feels important which I like to post whenever geometric algebra comes up:<p>Just because multivectors are intuitively superior doesn&#x27;t mean GA is a solved pedagogical solution to rotations. It is itself very strange and unintuitive. In particular there is no satisfying explanation for what the geometric product means that I&#x27;m aware of (and I have read more-or-less everything there is on the subject). Certain restrictions of the product have a geometric interpretation but the overall operation doesn&#x27;t. The product tends to be introduced in a just-so way: look, an operation! How neat! But if you&#x27;re a student who&#x27;s already wondering &quot;wtf is a quaternion and why does this work&quot; you&#x27;re not going to be much better off wondering &quot;wtf is a geometric product and why does it work&quot;.<p>I happen to think that the superior pedagogical solution is to do away with the geometric product as well and just focus on rotations as an application of the exponential map [<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Exponential_map_(Lie_theory)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Exponential_map_(Lie_theory)</a>]. That is, quaternions emerge like this:<p>1. apply rotations via the exponential map acting on rotation operators: e^(iB) = 1 + (iB) + (iB)^2&#x2F;2! + ...<p>2. in a flash of insight, realize that rotating vectors with two half-rotations is more stable than one full rotation: e^(iB) v =&gt; e^(iB&#x2F;2) v e^(-iB&#x2F;2)<p>I don&#x27;t really understand the point of (2). I remember hearing that it works better in higher dimensions but couldn&#x27;t tell you why.<p>But the point is, the useful properties -- like avoiding gimbal lock -- follow from just oriented planes and the exponential map. Gimbal lock is avoided by expressing rotations as a single rotation around an arbitrary axis, instead of, say composing Euler angles around fixed axes. But you don&#x27;t need to mention the geometric product anywhere for this.<p>Anyway I think that this is a relatively &#x27;unsolved&#x27; space, pedagogically. There is probably a really good explanation of why this all works that feels like it is still missing and doesn&#x27;t involve any magic handwaving steps at all.
评论 #29513567 未加载
评论 #29514627 未加载
评论 #29513696 未加载
SideQuark超过 3 年前
Having written professionally about quaternions and GA, and having implemented them multiple times in professional engines, GA is simply slower and worse to use (until you replace them in the special case and put back quaternions).<p>I recommend every 3D engine keep quaternions - they work well for their task.<p>Here&#x27;s [1] one example from the godfather of GA demonstrating how poorly GA performs<p>[1] <a href="https:&#x2F;&#x2F;webspace.science.uu.nl&#x2F;~kreve101&#x2F;asci&#x2F;GAraytracer.pdf" rel="nofollow">https:&#x2F;&#x2F;webspace.science.uu.nl&#x2F;~kreve101&#x2F;asci&#x2F;GAraytracer.pd...</a>
评论 #29515532 未加载
kilovoltaire超过 3 年前
Since there&#x27;s currently an article about quaternions on the front page, it felt like a good time to bring up bivectors, which in my opinion are a much more elegant way to do rotations.<p>Particularly, I think this part is insightful:<p>&gt; In 3D, a bivector has three coordinates, one per plane: (xy, xz, and yz). Vectors also have three coordinates, one per axis (x, y and z). Each plane is perpendicular to one axis. This is a coincidence that only happens in three dimensions and it is why historically we have been confusing bivectors with vectors.
评论 #29513405 未加载
评论 #29513555 未加载
ogogmad超过 3 年前
Off topic: Are the &quot;dual-complex numbers&quot;* used in 2D game engines? They&#x27;re certainly a part of GA.<p>The term <i>dual-complex numbers</i> is an unfortunate name for what I&#x27;m referring to, which is a 4D number system for representing rigid body motions of 2D space. There is an analogue of SLERP for them for interpolating between rigid body motions. So you would expect the answer to be yes.<p>Maybe this isn&#x27;t the right forum for this question.<p>* - <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Dual-complex_number#:~:text=The%20dual%2Dcomplex%20numbers%20make,complex%20numbers%20is%20non%2Dcommutative" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Dual-complex_number#:~:text=Th...</a>.
dr_orpheus超过 3 年前
Previous discussion on this article: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=18365433" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=18365433</a>
评论 #29513394 未加载
armchairhacker超过 3 年前
I like the author&#x27;s general idea that there should be a separate, mostly-opaque type for 2D and 3D angles.<p>2D angles are represented by floats, and 3D angles are represented by Quaternions. Which is fine internally, but a smart language should provide an inline wrapper type.<p>Typing 2D angles as floats presents issues when wrapping: x and 2pi * x will look and mostly function the same, but can lead to edge cases e.g. comparisons and loss of precision.<p>Typing 3D angles makes them easier to understand, since you won&#x27;t be doing high-level mathematical operations, you&#x27;ll just be rotating to face x or rotating by y degrees perpendicular to vector z.
ldd超过 3 年前
The first sentence in the first slice opens as follows: &quot;I have always found it important to actually understand the things I am using.&quot;<p>I think there is a certain &#x27;magic&#x27; in not understanding certain concepts fully. It&#x27;s probably why I like maths and heavily dislike physics and chemistry. I do not want to make sense of this world. I want to see &quot;the volume of a sphere is 4&#x2F;3<i>PI</i>r^3&quot; and in some sense see it as an incantation that one would make when casting magic in an RPG. Once you take some calculus, it is a pretty easy formula to derive (integrate?), but there is an allure, an invitation to do some really interesting math just for itself. It fires up our inner curiosity, if you want.<p>So anyways, I am neither addressing the title&#x27;s question nor would I really mind if quaternions were replaced in game engines, but I thought it was important to voice the opinion that sometimes it&#x27;s ok to not understand something.
评论 #29514311 未加载
评论 #29514426 未加载
评论 #29514293 未加载
评论 #29515124 未加载
评论 #29514258 未加载
评论 #29514600 未加载
vazgriz超过 3 年前
&gt; their API is the same<p>&gt; in fact, they are isomorphic<p>&gt; The change is simple and the code remains almost the same, but the understanding grows a lot.<p>Does that mean you could rename &#x27;class Quaternion&#x27; to &#x27;class Rotor&#x27; and be done? I watched the video on rotors and some other videos on quaternions and I found them exactly as unintuitive as each other. I don&#x27;t really see any advantage to using rotors and I&#x27;m quite happy to continue treating quaternions as black boxes.<p>The article says that rotors are better since they can be generalized to any number of dimensions, unlike quaternions which only work in 3D. But that only seems useful to one person: Marc ten Bosch, the guy who writes games in 4D.
评论 #29515228 未加载
lacker超过 3 年前
To me a 3d rotation is a linear transformation from a 3d vector space to itself, so the natural way to represent it is as a 3x3 matrix.<p>Mathematically, this isn&#x27;t an unusual way to look at it; you can read the Wikipedia page on this way of representing rotations. The nice thing is that it works basically the same as a 2d rotation, you just have one more row and column in your matrix.<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Rotation_matrix" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Rotation_matrix</a><p>I think this is simpler than any of quaternions, rotors, bivectors, or exponential maps.
评论 #29514527 未加载
dang超过 3 年前
Ongoing related thread:<p><i>Quaternions</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29510237" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29510237</a>
Grustaf超过 3 年前
Here comes the Geometric Algebra evangelists again.
klodolph超过 3 年前
I think there&#x27;s a lot of fuss here to come up with something which has the same structure (isomorphic) and same representation &#x2F; encoding as quaternions, while trying to avoid calling them quaternions. Part of math pedagogy is getting comfortable with terminology and when to say that two things are &quot;the same thing&quot;. You understand a structures (like quaternions, like rotors) by using both axiomatic approaches (what are the properties of these things?) and from constructive approaches (how do we build these things?)<p>Take the real numbers, for example. They are intuitively simple, but if you take an analysis class, you&#x27;ll be asked to rigorously prove that your different approaches to understanding real numbers are equal to each other, and therefore interchangeable. You can take your axiomatic approach (real numbers are an ordered field, where each nonempty set bounded above has a least upper bound). You can construct real numbers as decimal numbers with an infinite number of digits past the decimal point. You can construct real numbers as limits of series of fractions. All of these approaches &quot;are&quot; the real numbers. No one version is privileged over the others. By understanding these different approaches, you get a better understanding of the real numbers.<p>Same is true of quaternions, but here, it seems that we&#x27;re being sold an idea that one version is superior and the other versions are inferior. This is, I believe, a bad pedagogical approach. There are certain advantages to thinking of quaternions in terms of a scalar component and 3D imaginary component. For one thing, the imaginary component points in the direction of the axis of rotation! That&#x27;s pretty handy, for visualizing quaternions as rotations. This article takes the viewpoint that there is no reason to think of quaternions as anything other than rotors and plane reflections--again, this is bad pedagogy, because people should be encouraged to think of mathematical objects in different ways, and use whichever way that they find convenient for the problem, or convenient for their own mental model. No one approach is privileged. As a mathematician, reading this article, all I see at the end is &quot;Oh, you want to use quaternions, but you don&#x27;t want to <i>call</i> them quaternions.&quot;<p>Perhaps we need a more in-depth article on the notion of rotations explained for non-mathematicians, something that, at the very least, incorporates the relationship between axis-angle representations and quaternions&#x2F;rotors, because these two different representations are <i>not</i> isomorphic, and they are related to each other through calculus, the exponential map, and Lie algebra. It&#x27;s also worthwhile to think what the tangent space is for unit quaternions. If you incorporate the different approaches to representing rotations, and don&#x27;t try to sell one as being &quot;the best&quot; representation, I&#x27;d love to read <i>that</i> article.
评论 #29516099 未加载