I have a problem with the rotation of the objects via sleitnick’s Quaternion Module
Problem: When any axis (X, Y, Z) is equal to 90 degrees, then the other two axes have the same direction of rotation.
If you don’t understand what I’m talking about, then look at this: Gimbal lock - Wikipedia
Video of problem:
Script:
local quatModule = require(game.ReplicatedStorage.Quaternion)
local cube = workspace.CUBE
local cubePos = cube:GetPivot().Position
local axis = {X = 0, Y = 0, Z = 0}
local quat = quatModule.euler(math.rad(axis.X), math.rad(axis.Y), math.rad(axis.Z)) -- Creating Quaternion from Euler Angles
local newCFrame = CFrame.new(cubePos.X, cubePos.Y, cubePos.Z, quat.X, quat.Y, quat.Z, quat.W)
cube:PivotTo(newCFrame)
I’ve already tried:
- Change the rotation order (XYZ, ZYX, YXZ, etc.)
- Use other Quaternion modules
- Converting Quaternion to CFrame (Quaternion:ToCFrame(position))
- The solutions I found on the forum did not help me
I am grateful for any suggestion to solve this problem and i use a translator, so my text may be incorrect