diff --git a/episodes/10-defensive.md b/episodes/10-defensive.md index c945a9627..561889b34 100644 --- a/episodes/10-defensive.md +++ b/episodes/10-defensive.md @@ -109,6 +109,9 @@ representing the lower left and upper right corners of the rectangle. In order to do some calculations, we need to normalize the rectangle so that the lower left corner is at the origin and the longest side is 1.0 units long. + +![](fig/rectangle_normalization.svg){alt='Rectangle normalization follows one of two paths depending on which side is longer.'} + This function does that, but checks that its input is correctly formatted and that its result makes sense: diff --git a/episodes/fig/rectangle_normalization.svg b/episodes/fig/rectangle_normalization.svg new file mode 100644 index 000000000..6d4b465da --- /dev/null +++ b/episodes/fig/rectangle_normalization.svg @@ -0,0 +1,255 @@ + + + + + + + + + + + + + + + + + + (x0, y0) + x0 + y0 + dx = x1 - x0 + 1.0 + 1.0 + scaled + scaled + dy = y1 - y0 + (x1, y1) + + + + + + dx > dy + dy > dx + + +