CFrame:ToObjectSpace what exactly can this be used for

I do not know what ToObjectSpace can be used for From what I have been reading, toObjectSpace just returns offSet from a to b. I tried to play around with it and I got this

local YellowCube = game.Workspace.YellowCube
local PurpleCube = game.Workspace.PurpleCube

local offSet = PurpleCube.CFrame:ToObjectSpace(YellowCube.CFrame) 


output – -0.5, 2.99999619, 0.500137329, 1, 0, 0, 0, 1, 0, 0, 0, 1

So what exactly am I supposed to be using this for?

You use it when you want to take a CFrameB and make it’s reference relative to CFrameA. This can be useful for rotations about a point.

If you have a point A = <x, y, z> and a point B = <w, j, k> then the object space of B onto A is just <a - w, y - j, z - k>. This is like making point Athe origin and redefining pointB` in the terms of the new origin.

Example. You have the point A which is <1, 9, 3> and you have a point B which is <3, 0, 2>.
The position of B in terms of A’s object space would be <1 - 3, 9 - 0, 3 - 2> which is <-2, 9, 1>. What this is really saying is that B is located at A + the offset of <-2, 9, 1>.


So it’s basically redifining the position or rotation of a CFrame?