This seems to me like it might be a bug.
At line 1224, your well is kicking off to horizontal in the x-direction. When you specify a kickoff radius, the code draws a well along the edge of a circle with that radius until the well points in the x-direction. circle_center is the center of that circle. The reason temp_trajectory(i,2) uses cur_location at line 1224 is because the well trajectory is not changing in the y-direction.
At line 1262, you’re kicking off to horizontal in the y-direction and the trajectory should not be changing in the x-direction. I would think that in this case, temp_trajectory(i,1) should use cur_location(1).
And since at line 1309 you’re moving in along the circle in x,y, and z temp_trajectory(i,2) should use circle_center(2).
Michael