Getting the translational component of a CFrame (CFrame.Translation)

As a roblox developer, it is a nuisance to get just the translational component of a CFrame without extraneous conversion between Vector3 and CFrame.

The CFrame.Position property provides the positional/translational component of a CFrame, but in the form of a Vector3.

The current methods to get a CFrame with no rotational component, example being an arbitrary cframe, are as follows:

local methodOne = CFrame.new(example.Position) -- usual method --
-- 0, 10, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1

local methodTwo = (example * example.Rotation:Inverse()) -- floating point errors, not really used --
-- 0, 10, 0, 0.99999994, 0, 0, 0, 0.999999881, -2.98023224e-08, 0, -2.98023224e-08, 0.999999881

These methods work, but add in extra class construction or math along with more writing if you wish to use this for CFrame math.

There was a similar issue of getting a CFrame with just the rotational component of a CFrame, where (example - example.Position) was used. To save hassle here, the CFrame.Rotation property was introduced.

A similar approach could be taken here, by introducing a CFrame.Translation property that returns a CFrame with just the translational component, instead of a Vector3 like CFrame.Position.

If this issue was addressed, it would improve my development experience because it would save having to convert between Vector3 and CFrame as often and provide a smoother coding experience when working with CFrames.

7 Likes