# Cool short quaternion vs Euler angles comparison

[quote] But here you are rotating using the part’s current cframe angles.
My goal was to have it where the part’s existing cframe angle orientation would have no effect on the rotation it will undergo.

``````--- this orientation
--- interpolate to

Here you could see that both angle rotations were constructed without using the part’s cframe, which is important in particular when I have animation sequences that should cancel each other out. Yet, the part can still rotate on the same axis.

The current way you have:

``````part.CFrame = part.CFrame * CFrame.new(0, 0, 0, xs[2], ys[2], zs[2], math.sqrt(xs[1] + ys[1] + zs[2]))
--- to
part.CFrame = part.CFrame * CFrame.new(0, 0, 0, xs[2], ys[2], zs[2], xs[1])``````

You would have to set the part to rotate on one axis and then rotate on the other axis?
Because it couldn’t be done without the part already rotated the first way. [/quote]

No the way it works is you set the amount you want to rotate. It has the rotation parent structure of your choice on top then however roblox deals with setting the other coordinates. An example of the other coordinates would be:

``````-- The rest of the other code.
wait(1)
xs = {changes("x", x)}
ys = {changes("y", y)}
zs = {changes("z", z)}
print(xs[2], ys[2], zs[2])
part.CFrame = CFrame.Angles(xs[2], ys[2], zs[2], ys[1])
wait(1)
xs = {changes("x", x*2)}
zs = {changes("z", 0)}
print(xs[2], ys[2], zs[2])
part.CFrame = CFrame.Angles(xs[2], ys[2], zs[2], xs[1])``````

Has nothing to do with the parts structure. I just use the * to keep on adjusting the CFrame.

Neat, I just recently explored Quaternions. I don’t have a thorough understanding behind all of it, but I have a general idea on it. Even made some Quaternion class for fun. I’ve been planning on making some animation system using Quaternions at some point, but haven’t gotten to it yet. Anyways, here are some resources you can check out if you’re interested in using/understanding Quaternions.

A Roblox user called “Quaternion” has two models that could be useful if you don’t wanna know how it works.
Quaternion Library
Tweening Library

Stravant also made some source code some time back.
Stravant’s Quaternion Interpolate Source

I have some source examples that might be interesting to look at. Nice and simple, I think
Modulescript class with metamethods and stuff, focused towards interpolation between two CFrames [Quaternion:GetFrames(cf1,cf2,frames)]
Example source of my first attempt - try it out in studio

Here is some information I used on the subject. If you’re confused, just google search for a while.
Wikipedia: Slerp [Scroll down to Quaternion Slerp]
Not directly useful, but might have better and faster alternatives to Quaternion slerping
Basic Quaternion properties with code
General overview of rotation with Quaternions

Keep in mind that unless you want to understand all the math behind it, all the talk about imaginary numbers can be ignored when trying to make your own Quaternion function/class/whatever (particularly with the wikipedia.org/Quaternions article). Could help lower the complexity if you’re learning with a purely programming perspective (probably the only perspective worth looking at for Quaternions).

I would just like to comment on the absurdity of this statement earlier in the thread:
“I even asked my math teacher - which he then asked other math teachers and they had no clue on how to calculate them.”

Your teachers aren’t magical oracles of knowledge, Quaternions are a highly domain specific concept that doesn’t have much use outside of 3D computer simulation / graphics and some very specialized pure mathematics. And even if you asked someone who did understand quaternion mathematics the first thing they would do if you asked them how to construct one efficiently would be to go grab their trusty notes / textbook on the subject and find the solution in there, they’re not going to be able to rattle some formulas off to you from the top of their head or something like that.

[quote] I would just like to comment on the absurdity of this statement earlier in the thread:
“I even asked my math teacher - which he then asked other math teachers and they had no clue on how to calculate them.”

Your teachers aren’t magical oracles of knowledge, Quaternions are a highly domain specific concept that doesn’t have much use outside of 3D computer simulation / graphics and some very specialized pure mathematics. And even if you asked someone who did understand quaternion mathematics the first thing they would do if you asked them how to construct one efficiently would be to go grab their trusty notes / textbook on the subject and find the solution in there, they’re not going to be able to rattle some formulas off to you from the top of their head or something like that. [/quote]

I wasn’t implying he should know - I was giving my experience. I asked him he had no idea, I couldn’t figure it out so I gave out. I was essentially just giving background.