40 is the radius of the arc, 50 the start angle of the start point and 51 the end angle of the end point. Both angles are in radians and measured at the centre point.
The (if (> sa ea)...) is needed in case the start angle is greater than the end angle (the arc passes through 0 (zero) radians). Arcs and circles are always counter clockwise irrespective of how they are constructed