Worked example · Computer Science · Year 7 · Beginner

Writing Precise Instructions to Draw Vector Shapes on a Grid

LNF: Numeracy → Using geometry skills → Position · DCF: Problem-solving and modelling

What this is

A complete model response and answer key for the cover teacher and for marking. Headline answers: Step 1 fixed commands: Command 4 = LINE_TO (5, 8), Command 6 = LINE_TO (7, 10), Command 10 = LINE_TO (11, 10). Step 2 measurements: base width = 10 units, wall height = 8 units, outer rectangle perimeter = 36 units, full castle tower perimeter = 44 units. Step 3 shield script: MOVE_TO (5, 7), LINE_TO (11, 7), LINE_TO (11, 5), LINE_TO (8, 3), LINE_TO (5, 5), LINE_TO (5, 7).

Step 1: Spot and fix the 3 coordinate bugs in the castle tower

Command no. Buggy command in file What mistake was made? Corrected command
Command 4 LINE_TO (5, 9) The y-coordinate was 9 instead of 8, so the left-hand gap only went down 1 unit instead of 2 units and made the gap sloping. LINE_TO (5, 8)
Command 6 LINE_TO (10, 7) The x and y coordinates were swapped (plotted up first, across second). It went to (10, 7) instead of the top-left of the middle merlon at (7, 10). LINE_TO (7, 10)
Command 10 LINE_TO (11, 11) The y-coordinate was 11 instead of 10, making the right-hand merlon spike 1 unit higher than the top of the tower. LINE_TO (11, 10)

(b) Completed Grid A (showing both the corrected castle tower and the Step 3 shield):

0123 4567 891011 12131415 16 0123 4567 891011 12

Identifies all three coordinate errors (wrong vertical depth, transposed x and y coordinates, and wrong vertical height) and plots the symmetrical shape accurately. Evidences criteria 1 and 2.

Step 2: Calculate side lengths and the perimeter of the castle tower

Measurement Calculation using coordinates Answer (grid units)
(a) Width of tower base from (3, 2) to (13, 2) 13 − 3 = 10 10 units
(b) Height of left wall from (3, 2) to (3, 10) 10 − 2 = 8 8 units
(c) Perimeter of simple outer rectangle (3, 2), (3, 10), (13, 10), (13, 2) 10 + 8 + 10 + 8 36 units
(d) Full perimeter of the castle tower (including the four 2-unit vertical steps in the battlements) Base (10) + left wall (8) + right wall (8) + 5 horizontal top pieces (2 + 2 + 2 + 2 + 2 = 10) + 4 vertical steps in gaps (2 + 2 + 2 + 2 = 8) = 36 + 8 44 units

Uses coordinate subtraction to find horizontal and vertical lengths and accounts for the four 2-unit vertical steps inside the battlements when finding the full perimeter. Evidences criterion 3.

Step 3: Write the vector commands for the symmetrical shield icon

Step What the virtual pen does Vector command
1 Move pen to top-left corner A without drawing MOVE_TO (5, 7)
2 Draw top horizontal edge across to top-right corner B LINE_TO (11, 7)
3 Draw right vertical edge down to right shoulder C LINE_TO (11, 5)
4 Draw sloping edge down to the bottom point D on the mirror line LINE_TO (8, 3)
5 Draw sloping edge up to left shoulder E LINE_TO (5, 5)
6 Draw left vertical edge back up to A to close the shield LINE_TO (5, 7)

Starts with MOVE_TO, uses LINE_TO for each edge in clockwise order, and returns to (5, 7) to close the polygon. Evidences criterion 4.

Step 4: Explain how vector graphics scale

A vector graphic stores the badge as mathematical coordinates and line instructions rather than fixed pixels, so when it is enlarged onto a 3-metre sports hall banner the computer recalculates the lines and keeps every edge completely sharp. A pixel (bitmap) image would stretch its fixed squares and look blocky and blurred. To double the size of the badge from (0, 0), the computer multiplies every x-coordinate and every y-coordinate by 2.

Explains why vector graphics scale without losing quality and links scaling to multiplying coordinates by a scale factor. Evidences criterion 4.

If you finish early: answers

Why this response is secure