@futurebird @GezThePez I can confirm that this was something that confused young teenaged me. Not so much the transition but the fact that there wasn't a transition. It wasn't until I learned about affine transforms (a tiny bit at A level, most at university) that I realised that it even was possible to take something from one form of expression and mechanically translate it to the other.
This is often also a special case of the distinction between imperative and declarative programming.
You wrote both of these as imperative, but, from your original example, the goto
is unusual. The way that this is normally written (when introducing children to it) is declaring that a line exists which is drawn for all rho where sin(rho) = cos(rho)
, whereas the second form is explicitly imperative (you're giving commands to a turtle). I wouldn't normally write the first form with goto
, I'd write it just setting pixels.
Your third example is also interesting because it's very much a declarative form: a circle is defined as all points that are equidistant in a 2D plane from a defined point. And realising that lets you derive your first form because the first form is 'just' the definition of all possible triangles where the hypotenuse length is a constant. But all of these are forms that provide continuous functions that specify the locations of all of the points on a line, whereas the turtle one is a set of instructions.
You can turn the declarative forms into equivalent imperative forms (as you did) by saying 'for each point in some discretised form, draw a line segment or pixel that approximates it'. But transforming it to the imperative form for the turtle is much harder because the quantisation becomes more explicit.
And this might be why I haven't done computer graphics since I finished my PhD.