|
how do I get the rotation of a CFrame..? |
|
|
|
^ y u not answering for real :|? |
|
Ulrakid11Join Date: 2010-12-31 Post Count: 1587 |
One way would be to return or print workspace.Part.CFrame or whatever it's called. The last 9 digits are the rotation matrix. |
|
|
^ ik that, but how to extract the last digits?
like, get 3 numbers for the rotation??
like
CFrame.Angles(num,num,num)?
from
Workspace.Part.CFrame |
|
|
|
print(Workspace.Partname.Rotation) |
|
|
^
no, not .Rotation, i want CFrame.Angles(x,y,z) |
|
|
bg = script.Parent
t = bg.Parent
while wait() do
local x,y,z = t.X.Value,t.Y.Value,t.Z.Value
bg.cframe = CFrame.Angles(x,y,z)
end
Workspace.ChildAdded:connect(function(c)
if c.Name == "Rocket " then
cf = CFrame.new(script.Parent.Position,c.Position)
wait()
--so this is where I need to get the CFrame.Angles from cf, and get the .X .Y and .Z of it, so that t.X.Value = .X of it, etc
end
end) |
|
|
function CFrameAngles(CFrame)
Matrix1, Matrix2, Matrix3, Matrix4, Matrix5, Matrix6, Matrix7, Matrix8, Matrix9, Matrix10, Matrix11, Matrix12, = select(3, Workspace.BasePlate.CFrame:components())
X,Y,Z = --Calculation to turn Matrix stuff into X,Y,Z help???
return CFrame.Angles(X,Y,Z)
end
|
|
|
@island
I meant a new post, asking for a rotation matrix to x,y,z axis converter
Plus you forgot to give me credit... |
|
|
@war
sorry, I guess?
I'm still trying to figure this out.. |
|
|
How exactly do you turn the matrix to axis?
R00 R01 R02
R10 R11 R12
R20 R21 R22
Now, R00, R10, R20 make up X, R01, R11, R21 make up y, and R02, R12, R22 make up Z
But HOW do you convert them? |
|
|
I failed on that function I gave you, there's only 9 matrix values not 12. (oops)
Anyway, I did some more research and I think I got your function;
function CFrameAngles(CFrame)
local Matrix00, Matrix01, Matrix02, Matrix10, Matrix11, Matrix12, Matrix20, Matrix21, Matrix22 = select(3, Workspace.BasePlate.CFrame:components())
local X,Y,Z = math.atan2(-Matrix12, Matrix22), math.asin(Matrix02), math.atan2(-Matrix01, Matrix00)
return CFrame.Angles(X,Y,Z)
end
So um, who needs ToEulerAnglesXYZ ??? |
|
|
toEulerAnglesXYZ is just longer than Angles. We used to only have toEulerAnglesXYZ.
It's more preferrable that you use Angles. |
|
Bebee2Join Date: 2009-05-17 Post Count: 3985 |
Fun fact - The last row of ROBLOX's matrix is equivalent to the negative lookVector.
Calculating X and Y angle from a unit vector is valid using almost the same equation. |
|
|
@drag
ToEulerAnglesXYZ is a method
Angles is a constructor
@be
I did not know that. That could come in handy. |
|