Shows a triangle tool within the GraphTool.
Download file: LineSegmentGraphTool.pg
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'parserGraphTool.pl', 'PGcourse.pl');
Preamble
Load the parserGraphTool.pl macro to be able to use the GraphTool.
$sx1 = random(-8, 8);
$sy1 = random(-8, 8);
do { $sx2 = random(-8, 8); $sy2 = random(-8, 8); }
until $sx2 != $sx1 || $sy2 != $sy1;
$gt = GraphTool("{segment, solid, ($sx1, $sy1), ($sx2, $sy2)}",)
->with(availableTools => [ 'SegmentTool', 'FillTool', 'SolidDashTool' ]);
Setup
The graph tool is created with the correct answer
{ segment, solid, ($sx1, $sy1), ($sx2, $sy2) }, with unique
points ($sx1, $sy1) and ($sx2, $sy2). For a
correct answer, the line segment must have the given the endpoints and
be solid.
Mulitple line segments can be added to the graph tool, however, if a triangle or quadrilateral is desired, see Triangle Graph Tool and Quadrilateral Graph Tool for more appropriate tools.
BEGIN_PGML
Graph the line segment between the points [`([$sx1], [$sy1])`] and
[`([$sx2], [$sy2])`].
[_]{$gt}
END_PGML
Statement
This asks the student to graph the line segment with the given
endpoints. The code [_]{$gt} inserts the graph tool.
BEGIN_PGML_SOLUTION
The correct answer is
[!A graph of the line segment from ([$sx1], [$sy1]) to ([$sx2],[$sy2])!]{$gt}
END_PGML_SOLUTION
ENDDOCUMENT();
Solution
To show the graph with alternate text we use the PGML image construct
[! !]{$gt}, where the alternate text is placed within the
[! !].