Quaternions and 3d rotation, explained interactively
5:59

Quaternions and 3d rotation, explained interactively

3Blue1Brown 26.10.2018 1 477 631 просмотров 35 065 лайков

Machine-readable: Markdown · JSON API · Site index

Поделиться Telegram VK Бот
Транскрипт Скачать .md
Анализ с AI
Описание видео
Go experience the explorable videos: https://eater.net/quaternions Ben Eater's channel: https://www.youtube.com/user/eaterbc Help fund future projects: https://www.patreon.com/3blue1brown An equally valuable form of support is to simply share some of the videos. Special thanks to these supporters: http://3b1b.co/quaternion-explorable-thanks Previous video on Quaternions: https://youtu.be/d4EgbgTm0Bg Nice explanation of Gimbal Lock: https://youtu.be/zc8b2Jo7mno Great videos comparing Euler angles and quaternions, from the perspective of an animator: https://youtu.be/syQnn_xuB8U https://youtu.be/4mXL751ko0w Music by Vincent Rubinetti: https://vincerubinetti.bandcamp.com/album/the-music-of-3blue1brown ------------------ 3blue1brown is a channel about animating math, in all senses of the word animate. And you know the drill with YouTube, if you want to stay posted on new videos, subscribe: http://3b1b.co/subscribe Various social media stuffs: Website: https://www.3blue1brown.com Twitter: https://twitter.com/3blue1brown Reddit: https://www.reddit.com/r/3blue1brown Instagram: https://www.instagram.com/3blue1brown_animations/ Patreon: https://patreon.com/3blue1brown Facebook: https://www.facebook.com/3blue1brown

Оглавление (6 сегментов)

Intro

In a moment, I'll point you to a separate website hosting a short sequence of what we're calling explorable videos. It was done in collaboration with Ben Eater, who some of you may know as that guy who runs the excellent computer engineering channel. And if you don't know who he is, viewers of this channel would certainly enjoy the content of his, so do check it out. This collaboration was something a little different though, for both of us, and all of the web development that made these explorable videos possible is completely thanks to Ben. I don't want to say too much about it here, it's really something you have to experience for yourself, certainly one of the coolest projects I've had the pleasure of working on. Before that though, if you can contain your excitement, I want to use this video as a chance to tee things up with a little bit of surrounding context. So to set the stage, last video I described quaternions, a certain 4-dimensional number system that the 19th century versions of Wolverine and the old man from Home Alone called evil for how convoluted it seemed at the time.

Quaternions

And perhaps you too are wondering why on earth anyone would bother with such an alien-seeming number system. One of the big reasons, especially for programmers, is that they give a really nice way for describing 3D orientation, which is not susceptible to the bugs and edge cases of other methods. I mean they're interesting mathematically for a lot of reasons, but this application for computer graphics and robotics and virtual reality and anything involving 3D orientation is probably the biggest use case for quaternions. To take one example, a friend of mine who used to work at Apple, Andy Matuszczak

Example

delighted in telling me about shipping code to hundreds of millions of devices that uses quaternions to track the phone's model for how it's oriented in space. That's right, your phone almost certainly has software running somewhere inside of it that relies on quaternions.

Euler angles

The thing is, there are other ways to think about computing rotations, many of which are way simpler to think about than quaternions. For example, any of you familiar with linear algebra will know that 3x3 matrices can really nicely describe 3D transformations. And a common way that many programmers think about constructing a rotation matrix for a desired orientation is to imagine rotating an object around three easy-to-think-about axes, where the relevant angles for these rotations are commonly called Euler angles. And this mostly works, but one big problem is that it's vulnerable to something called gimbal lock, where when two of your axes of rotation get lined up, you lose a degree of freedom. And it can also cause difficulties and ambiguities when trying to interpolate between two separate orientations. If you're curious for more of the details, there are many great sources online for learning about Euler angles and gimbal lock, and I've left links in the description to a few of them. Not only do quaternions avoid issues like gimbal lock, they give a really seamless way to interpolate between two three-dimensional orientations, one which lacks the ambiguities of Euler angles, and which avoids the issues of numerical precision and normalization that arise in trying to interpolate between two rotation matrices.

Complex numbers

To warm up to the idea of how multiplication in some higher-dimensional number system might be used to compute rotations, take a moment to remember how it is that complex numbers give a slick method for computing 2D rotations. Specifically, let's say you have some point in two-dimensional space, like 4, 1, and you want to know the new coordinates you'd get if you rotate this point 30 degrees around the origin. Complex numbers give a sort of snazzy way to do this. You take the complex number that's 30 degrees off the horizontal with magnitude 1, cos 30 degrees plus sin 30 degrees times i, and then you just multiply this by your point, represented as a complex number. The only rule you need to know to carry out this computation is that i2 equals negative 1. Then in what might feel like a bit of black magic to those first learning it, carrying out this product from that one simple rule gives the coordinates of a new point, the point rotated 30 degrees from the original. Using quaternions to describe 3D rotations is similar

Using quaternions

though the look and feel is slightly different. Let's say you want to rotate some angle about some axis. You first define that axis with a unit vector, which we'll write as having i, j, and k components, normalized so that the sum of the squares of those components is 1. Similar to the case of complex numbers, you use the angle to construct a quaternion by taking cosine of that angle as the real part, plus sin of that angle times an imaginary part, except this time the imaginary part has three components, the coordinates of our axis of rotation. Well, actually you take half of the angle, which might feel totally arbitrary, but hopefully that makes sense by the end of this whole experience. Let's say you have some 3D point, which we'll write with i, j, and k components, and you want to know the coordinates you'd get when you rotate this point by your specified angle around your specified axis. What you do is not just a single quaternion product, but a sort of quaternion sandwich, where you multiply by q from the left and the inverse of q from the right. If you know the rules for how i, j, and k multiply amongst themselves, you can carry out these two products by expanding everything out, or more realistically by having a computer do it for you. And in what might feel like a bit of black magic, this big computation will return for you the rotated version of the point. Our goal is to break this down and visualize what's happening with each of these two products. I'll review the method for thinking about quaternion multiplication described last video, and explain why half the angle is used, and why you would multiply from the right by the inverse. On the screen now and at the top of the description you'll find a link to eater. net slash quaternions, which is where Ben set up the explorable video tutorial, where I explain what's going on with this rotation computation. It's just really cool. Eater did something awesome here. So at the very least just take a couple minutes to go look at it, but I'd love it if you went through the full experience.

Другие видео автора — 3Blue1Brown

Ctrl+V

Экстракт Знаний в Telegram

Экстракты и дистилляты из лучших YouTube-каналов — сразу после публикации.

Подписаться

Дайджест Экстрактов

Лучшие методички за неделю — каждый понедельник