Bill the Lizard: SICP 2.50 – 2.51: Transforming and Combining Painters

Hey Bill. I'm having trouble understanding how the transform-painter procedure works. Specifically why the vector subtraction of the edge mappings of the argument frame by the new-origin is necessary. I would have thought the mapping of the new corners, i.e (m corner1) & (m corner2), could serve as the new edges of the transformed frame.I've done some calculation and I wonder if you can point out where i'm mixed up.Taking flip-vect as an example.Let flip-vect take as argument a frame with the following dimensions.Origin = (0, 0)Edge1 = (4, 0)Edge2 = (0, 4)Accordingly the mapping forumla would become(0,0) + x(4,0) + y(0, 4)In the case of flip-vect the origin, corner1, and corner2 passed as arguments to transform-vector are (0,1), (1,1) & (0,0) respectivelySo after placing them in the mapping formula, one after the other, we get the resultsnew-origin = (0,0)+0*(4,0)+1*(0,4) = (0,4)mapped-corner1 = (0,0)+1*(4,0)+1*(0,4) = (4,4)mapped-corner2 = (0,0)Now the transform-painter takes the final two results and subtracts them by the new-origin to build the new frame, resulting in a frame with the following dimensions. origin = (0,4) new-corner1 = (4,0) new-corner2 = (0,-4)Looking at these points on a coordinate plane it doesn't make sense, while the original corner results before the subtractions took place, do make sense. What am I doing wrong? The question was cross-posted on stack overflow (http://stackoverflow.com/questions/15541632/how-transform-painter-works-in-the-picture-language-in-sicp) but to respond to Michael's question here:The reason new-corner1 and new-corner2 are the difference of mapped-corner1 and mapped-corner2 from new-origin, is because the way `frame` has been defined. The triple (new-origin edge1 edge2) are not points but vectors, where edge1 and edge2 are vectors starting at new-origin. So, new-corner1 = (4,0) means that one edge goes from the new-origin at (0,4) to (0,4)+(4,0) = (4,4), and similarly the second edge goes from (0,4) to (0,4)+(0,-4) = (0,0). Source.


Яндекс.Метрика Рейтинг@Mail.ru Free Web Counter
page counter
Last Modified: April 18, 2016 @ 9:12 am