Adding Two CFrame Angles

I need to add two CFrame angles together, but when I do, It does not do what I expect.

local StartingAngle = CFrame.Angles(math.rad(73),0,math.rad(116))
local AddAngle = CFrame.Angles(math.rad(-13),0,math.rad(4))

local ResultantAngle = StartingAngle:ToWorldSpace(AddAngle)



local A = Vector3.new(StartingAngle:ToEulerAnglesYXZ())
print(math.round(math.deg(A.X)),math.round(math.deg(A.Y)),math.round(math.deg(A.Z)))

local A = Vector3.new(AddAngle:ToEulerAnglesYXZ())
print(math.round(math.deg(A.X)),math.round(math.deg(A.Y)),math.round(math.deg(A.Z)))

local A = Vector3.new(ResultantAngle:ToEulerAnglesYXZ())
print(math.round(math.deg(A.X)),math.round(math.deg(A.Y)),math.round(math.deg(A.Z)))

image
Why is it doing this? And how can I do this properly in the way I want?

Just do this


local StartingAngle = CFrame.Angles(math.rad(73),0,math.rad(116))
local AddAngle = CFrame.Angles(math.rad(-13),0,math.rad(4))

local ResultantAngle = StartingAngle * AddAngle

This is the way you should add cframes to each other

That gives the same result, I tried that in order to fix it and forgot to revert it when I posted this.

What if you switched around the way the two angles are being multiplied? The way they are multipled matters

That gives 60 8 124 for some reason, closer but not exactly.
Should I just extract the angles with :ToEulerAnglesYXZ() and then add them together that way? That seems so wrong.

local StartingAngle = CFrame.Angles(math.rad(73),0,math.rad(116))
local AddAngle = CFrame.Angles(math.rad(-13),0,math.rad(4))

local TrueVector = Vector3.new(StartingAngle:ToEulerAnglesYXZ())+Vector3.new(AddAngle:ToEulerAnglesYXZ())
local ResultantAngle = CFrame.Angles(TrueVector.X,TrueVector.Y,TrueVector.Z)
--Expected (60,0,120)


local A = Vector3.new(StartingAngle:ToEulerAnglesYXZ())
print(A.X,A.Y,A.Z)

local A = Vector3.new(AddAngle:ToEulerAnglesYXZ())
print(A.X,A.Y,A.Z)

local A = Vector3.new(ResultantAngle:ToEulerAnglesYXZ())
print(A.X,A.Y,A.Z)

Yea this works, but I don’t like it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.