Moving an object in circle

So I need to move an object in a circle and found this code HERE. I’ve tried the code and it works. I just need an explanation on some lines, specifically this lines:

        var worldLookDirection = target.position - transform.position;
        var localLookDirection = transform.InverseTransformDirection(worldLookDirection);

The ‘target.position’ is the position of the center of the circle right? Then why did he subtracte it to the object’s position and why did he used ‘InverseTransformDirection’? Isn’t the direction already in local space?(I’m not sure though).

Last is this line:

transform.forward = transform.rotation * localLookDirection;

My Question why did he need to change the object’s forward?
Also, what if I want to adjust the distance/radius between the object and the center?

Thanks in advance!

The first line gets the vector from the position to the target. That is what you get with subtraction, first one becomes the tip of the arrow while the second becomes the origin of the vector.

The second line takes that previous vector and converts it to local world of the object.

The last one takes the vector you just got and multiply with the current rotation, this will return a vector3 corresponding to the forward of the object.

In a way it is like if the object is constantly turning a little in the direction of the center and moving in that direction. Since it is not moving a lot, it creates a circle. If your start to rotate more, it will get closer to the center and inverse if you rotate less.

Another way, which I find more intuitive is to use cos/sin.