In the Lesson 8.3 activities we learned how to call a function with a parameter that had the robot trace a square of specified side length. In this activity we will work on the function definition itself by creating a function that draws an equilateral triangle. The pre-placed function definition block has the name filled in ("traceTriangle") as well as the name of the parameter ("sideLength").
|
Grid Size: S M L | Simple View: | MinView: |
|
Coord: x-axis y-axis | Grid Lines: x-axis y-axis | |||
Grid: | 12x12 inches | 24x24 inches | 36x36 inches | |
72x72 inches | 96x96 inches | 192x192 inches | ||
1x1 inches | 2x2 inches | Fraction: | ||
xy-Range: | ||||
|
||||
|
||||
Quad: | 1 Quadrant | 4 Quadrants | 1&4 Quadrants | |
Units: | US Customary | Metric | Ruler: |
Labels: |
|
|
|
Font
px
|
|
Tics Lines: |
|
Width
px
|
Hash Lines: |
|
Width
px
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
|
Add code to the traceTriangle function definition that (1) turns on the trace, (2) uses the driveDistance command to move the robot by a sideLength amount, (3) turns the robot left by 120 degrees, (4) uses driveDistance again to trace the next side, and so on for the rest of the triangle. The last command in the function definition should turn off the trace. Then add code to the Workspace that will use driveDistance and turn commands to move the robot to the point (8, 15) and then call the traceTriangle function to draw a red triangle of side length 12 (as shown in blue). |
|
|
|||||||||||
|
|||||||||||