here's an implementation of quaternion swizzling for super cheap 180° rotations in Unity, enjoy ❤
github.com/FreyaHolmer/Ma
Conversation
Replying to
this is basically what it's doing, but without doing a full quaternion multiplication
180° around world X =
Quat.Euler(180,0,0) * q
180° around self X =
q * Quat.Euler(180,0,0)
2
29
it's a *little* bit misleading to call it world vs self, it should really be extrinsic vs intrinsic, but people are more familiar with the first two, so hopefully it's not too bad
1
19
Replying to
That's a very cool trick! I just have to wonder how many practical use-cases there is where you *really* need the speed? (also I'd use an enum instead of an integer for the axis for readability)
2
1
2
Replying to
well, this one is extremely cheap and it has no precision errors, it's basically the best way to rotate a quaternion 180°
as for use cases, I had to reverse all rotations along a spline, so, yeah! they exist
7
Replying to
Ok so there's Euler, Euclid, Lots of others inbetween, then we come to modern era with Lorensen and Klein, Carmack, Coumans, and here we have Freya being a hero AGAIN. I'mma just cram you into this bag with other math and programming legends.
2
Replying to
thank you for the hints on understanding this.
as an aside, i am always on the lookout for jibberish that is meaningful jargon. (reticulating splines. who knew?)
i would love to connect quaternion swizzling to swizzle-clog used here in DB stress testing apple.github.io/foundationdb/t
1
Replying to
Pardon if you knew this but since enums are technically ints you can create an enum with members x, y, and z then you can be guaranteed to have been passed a valid axis.
1




