Line 62 defines the shape of the figure that the robot should draw (a circle in the case of this example). Points on a unit circle (with radius 1 and center point [0,0]) are defined by x = cos(theta) and y = sin(theta). The equation is simply multiplying by the radius to scale the circle and moving it to a different center point. See https://en.wikipedia.org/wiki/Unit_circle.
This equation generates a number of discrete points on the circle and the rest of the example uses those discrete points to calculate inverse kinematics solutions for the robot arm to reach these points. You could replace the circle with any other figure you have, as long as you have a way to calculate discrete points on the figure that the robot can follow.
For your question (1): for inverse kinematics purposes, the coordinates that the end effector should reach are always relative to the robot base. If you have global coordinates for end effector poses, you need to convert them to coordinates relative to the robot base and then you should be able to use that code.
Hope this helps,