Question On Look Vector and :Inverse()

How come this:

local cf = CFrame.new(-8, 0.5, 36, -1, 0, 8.94072443e-08, 0, 1, 0, -8.94072443e-08, 0, -1)

print(cf.LookVector)

--prints : -8.9407244274753e-08, -0, 1

Is the same as this:

local cf = CFrame.new(-8, 0.5, 36, -1, 0, 8.94072443e-08, 0, 1, 0, -8.94072443e-08, 0, -1)

print((cf - cf.Position):Inverse() * Vector3.new(0,0,-1))

--prints :  8.9407244274753e-08, 0, 1

As the CFrames orientation is inversed, how come the Z value in the second code sample doesn’t print out -1?

Better to visualize what CFrame inversing does:

Here is what you expected the angles are reversed, the 90 degree y rotation becomes -90 degree y rotation:

local cf = CFrame.Angles(0,math.rad(90),0)
local part = Instance.new("WedgePart")
part.Anchored = true
part.BrickColor = BrickColor.Red()
part.CFrame = cf
part.Parent = workspace

local part = Instance.new("WedgePart")
part.Anchored = true
part.BrickColor = BrickColor.Green()
part.CFrame = cf:Inverse()
part.Parent = workspace

The wedges are facing each other:

For your CF

the part is orientated at orientation (0,180,0). So if you inverse it making it (0,-180,0) it’s basically back to square 1 again. (If you manually input (0,-180,0) into orientation studio property it will become (0,180,0))

image

Do not think in terms of look vectors for visualizing why.

By themselves it doesn’t tell enough information, as there is the right vector and up vector which fully create the CF.

Use orientation as all three values correspond to the full rotation for your visualization. (Orientation is a lot nicer as well which is why Studio uses them as the default vs EulerAnglesXYZ or CFrame.Angles )

1 Like