Hello, so I’m trying to convert a quaternion to a CFrame Rotation Matrix but it doesn’t seem to look like the one im seeing in Blender though?
Any clue what could be wrong?
local part = workspace.Part
local x,y,z,w = .780,-0.158,0,.606
local r00 = 1 - 2*y*y - 2*z*z
local r01 = 2*x*y - 2*w*z
local r02 = 2*x*z + 2*w*y
local r10 = 2*x*y + 2*w*z
local r11 = 1 - 2*x*x - 2*z*z
local r12 = 2*y*z - 2*w*x
local r20 = 2*x*z - 2*w*y
local r21 = 2*y*z + 2*w*x
local r22 = 1 - 2*x*x - 2*y*y
local cframe = CFrame.fromMatrix(part.CFrame.Position,
Vector3.new(r00, r10, r20),
Vector3.new(r01, r11, r21),
Vector3.new(r02, r12, r22)
)
part.CFrame = cframe
maybe your quaternion is not normalized:
local magnitude = math.sqrt(x*x + y*y + z*z + w*w)
x, y, z, w = x / magnitude, y / magnitude, z / magnitude, w / magnitude
What does normalizing it do again?
Yeah normalizing it doesn’t work it still creates the same wacky rotation unlike the one im seeing in Blender
Roblox
Blender
did you do it like this:
local x, y, z, w = 0.707, 0, 0, 0.707
local magnitude = math.sqrt(x*x + y*y + z*z + w*w)
x, y, z, w = x / magnitude, y / magnitude, z / magnitude, w / magnitude
1 Like
Yeah I did it exactly like that but it’s not yielding the same results though
Did you use the numbers i gave you (90 degree around X axis)
Yeah but I’m not trying to get it to work with just 90 degrees around the X-Axis, im sure it will work but that’s not the rotation I want
This is the one I want
local x,y,z,w = .780,-0.158,0,.606
Thanks for trying eventually I got it to work!
@VonsRevenges
1 Like