Skip to content

Commit 8262836

Browse files
committed
Update the Vector graph tool as the functionality recently changed.
Also, add a Line Segment tool, which was also just added.
1 parent b7149c8 commit 8262836

File tree

2 files changed

+83
-14
lines changed

2 files changed

+83
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
## DESCRIPTION
2+
## Shows a triangle tool within the GraphTool.
3+
## ENDDESCRIPTION
4+
5+
## DBsubject(WeBWorK)
6+
## DBchapter(Sample Problems)
7+
## DBsection(Graph Tool)
8+
## Date(02/25/2025)
9+
## Institution(Missouri Western)
10+
## Author(Glenn Rice)
11+
## MO(1)
12+
## KEYWORDS('graph tool', 'vectors')
13+
14+
#:% name = Line Segment Graph Tool
15+
#:% type = Sample
16+
#:% subject = [geometry]
17+
#:% categories = [graph, graphtool]
18+
#:% see_also = [VectorGraphTool.pg, TriangleGraphTool.pg, QuadrilateralGraphTool.pg]
19+
20+
#:% section = preamble
21+
#: Load the PODLINK('parserGraphTool.pl') macro to be able to use the GraphTool.
22+
DOCUMENT();
23+
24+
loadMacros('PGstandard.pl', 'PGML.pl', 'parserGraphTool.pl', 'PGcourse.pl');
25+
26+
#:% section = setup
27+
#: This problem first finds two points with unequal x-values and unequal y-values.
28+
#: Below we will ask to drap the line segment between these two and add the correct answer
29+
#: `{ segment, solid, ($sx1, $sy1), ($sx2, $sy2) }` creates this line segment as a solid line.
30+
#:
31+
#:
32+
#: The line segment must have the given the endpoints.
33+
#:
34+
#: Mulitple line segments can be added to the graph tool, but note that there is a
35+
#: Triangle Graph Tool, PROBLINK('TriangleGraphTool.pg') and a Quadrilateral Graph too,
36+
#: PROBLINK('QuadrilateralGraphTool.pg') as well.
37+
$sx1 = random(-8, 8);
38+
$sy1 = random(-8, 8);
39+
do { $sx2 = random(-8, 8); $sy2 = random(-8, 8); }
40+
until $sx2 != $sx1 || $sy2 != $sy1;
41+
42+
$gt = GraphTool("{segment, solid, ($sx1, $sy1), ($sx2, $sy2)}",)
43+
->with(availableTools => [ 'SegmentTool', 'FillTool', 'SolidDashTool' ]);
44+
45+
#:% section = statement
46+
#: First, ask the question with the given points. Then add the `[_]{$gt}` to produce
47+
#: the graph tool within the problem.
48+
BEGIN_PGML
49+
Graph the line segment between the points [`([$sx1], [$sy1])`] and
50+
[`([$sx2], [$sy2])`].
51+
52+
[_]{$gt}
53+
END_PGML
54+
55+
#:% section = solution
56+
#: The important thing to note is that it is simple to add the correct graph using the
57+
#: method `generateAnswerGraph` as shown in the solution here. The PGML directive [ ]*
58+
#: needs a * for the graph tool to be rendered correctly.
59+
BEGIN_PGML_SOLUTION
60+
The correct answer is
61+
62+
[$gt->generateAnswerGraph]*
63+
END_PGML_SOLUTION
64+
65+
ENDDOCUMENT();

tutorial/sample-problems/VectorCalc/GraphToolVectors.pg

+18-14
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,38 @@ DOCUMENT();
2323
loadMacros('PGstandard.pl', 'PGML.pl', 'parserGraphTool.pl', 'PGcourse.pl');
2424

2525
#:% section = setup
26-
#: This finds three unique random points and sets up the GraphTool. The line
27-
#: `{ vector, solid, ($x1, $y1), ($x2, $y2) }` creates a vector from ($x1, $x2)
28-
#: to ($x2, $y2) as a solid line.
29-
$x1 = random(-8, 8);
30-
$y1 = random(-8, 8);
31-
do { $x2 = random(-8, 8); $y2 = random(-8, 8); } until $x2 != $x1 || $y2 != $y1;
32-
33-
$gt = GraphTool("{vector, solid, ($x1, $y1), ($x2, $y2)}")
34-
->with(availableTools => [ 'VectorTool', 'FillTool', 'SolidDashTool' ]);
26+
#: This problem asks for a vector with random endpoint $vx1, $vy1. Create this with
27+
#: `{ vector, solid (0,0), ($vx1, $vx2) }`.
28+
#:
29+
#: The answer check will give credit for a vector with same length and point in the
30+
#: same direction. The starting point does not need to be the origin.
31+
$vx1 = random(-8, 8);
32+
$vy1 = random(-8, 8);
33+
34+
$gt = GraphTool(
35+
"{vector, solid, (0, 0), ($vx1, $vy1)}"
36+
)->with(
37+
availableTools => ['VectorTool', 'FillTool', 'SolidDashTool' ]
38+
);
3539

3640
#:% section = statement
3741
#: First, ask the question with the given points. Then add the `[_]{$gt}` to produce
3842
#: the graph tool within the problem.
3943
BEGIN_PGML
40-
Graph the vector with initial point [`([$x1],[$y1])`] and terminal point
41-
[`([$x2],[$y2])`].
44+
Graph the vector [`\langle[$vx1], [$vy1]\rangle`].
4245

4346
[_]{$gt}
4447
END_PGML
4548

4649
#:% section = solution
4750
#: The important thing to note is that it is simple to add the correct graph using the
4851
#: method `generateAnswerGraph` as shown in the solution here. The PGML directive [ ]*
49-
#: needs a * for the HTML version to be rendered correctly.
52+
#: needs a * for the graph tool to be rendered correctly.
5053
BEGIN_PGML_SOLUTION
51-
The correct answer is
52-
54+
A correct answer is
5355
[$gt->generateAnswerGraph]*
56+
57+
But any vector with the same length and in the same direction would be correct as well.
5458
END_PGML_SOLUTION
5559

5660
ENDDOCUMENT();

0 commit comments

Comments
 (0)