Hey, I have been working on this math equation to convert a C1 to position, because I am programming an animation weld editor, basically it takes the old weld, and takes a new weld then edits all the animations using the difference in position, but my problem is C1s have really odd math, which requires alot of calculations to predict where it is, I’ve gotten almost half way there but I hit this brick wall, where if you rotate on 2 axis all the numbers are correct, but the second you rotate on 3 axis it becomes in correct
For example, with this CFrame:
(1, 1, 1) * CFrame.fromOrientation(math.rad(45), math.rad(45))
we get these coordinates (-0.70709228515625, -1.2071070671081543, 0.20709228515625)
Which if we plug into this calculation
X = -x*(cos(RY)*cos(RZ)) -y*(sin(RZ)*cos(RX))
We get the correct X value
But the second we change the RZ and plug it into the equation again we get different values, which doesnt make sense to me, here are all my calculations leading up to this point, if you can help in any way please do.
Case 1:
x = 1 (-1)
RY = 45 (-45)
+x, -z (-xcos(RY), -xsin(RY))Case 2:
x = 1 (-1)
RZ = 45 (-45)
+x, +y (-xcos(RZ), xsin(RZ))Case 3:
y = 1 (-1)
RX = 45 (-45)
+y, +z (-ycos(RX), ysin(RX))Case 4:
y = 1 (-1)
RZ = 45 (-45)
+y, -x (-ycos(RZ), -ysin(RZ))Case 5:
z = 1 (-1)
RX = 45 (-45)
+z, -y (-zcos(RX), -zsin(RX))Case 6:
z = 1 (-1)
RY = 45 (-45)
+z, +x (-zcos(RY), zsin(RY))Case 1 & Case 2: – Tested
X = -x*(cos(RY)*cos(RZ))
Y = x*(sin(RZ)*cos(RY))
Z = -x*sin(RY)Case 3 & Case 4: – Tested
X = -y*(sin(RZ)*cos(RX))
Y = -y*(cos(RX)*cos(RZ))
Z = y*sin(RX)Case 1 & 2 & 3 & 4:
X = -x*(cos(RY)*cos(RZ)) -y*(sin(RZ)*cos(RX)) – True until all 3 angles are rotated?