Vector-valued Parametric Line Segment--General

A Vector-value parametric line segment with a general paramterization

Complete Code

Download file: VectorLineSegment1.pg

PG problem file

Explanation

DOCUMENT();
loadMacros(
    'PGstandard.pl',           'PGML.pl',
    'parserParametricLine.pl', 'parserMultiAnswer.pl',
    'PGcourse.pl'
);

Preamble

The macro parseParametricLine.pl provides the ParametricLine function which will be the answer. The parserMultiAnswer.pl is needed since the answer blanks are interdependent.

Context("Vector");
Context()->variables->are(t => "Real");

$P = Point(4, 0);
$Q = Point(0, 2);
$V = Vector(-4, 2);

$t    = Formula("t");
$line = Vector("$P + $t * $V");

$multians = MultiAnswer($line, Real("0"), Real("1"))->with(
    singleResult => 0,
    checker      => sub {
        my ($correct, $student, $ansHash) = @_;
        my ($linestu, $astu,    $bstu)    = @{$student};
        my ($linecor, $acor,    $bcor)    = @{$correct};

        if ((ParametricLine("$line") == $linestu)
            && ($linestu->eval(t => $astu) == $line->eval(t => "0"))
            && ($linestu->eval(t => $bstu) == $line->eval(t => "1")))
        {
            return [ 1, 1, 1 ];

        } elsif ((ParametricLine("$line") == $linestu)
            && ($linestu->eval(t => $astu) == $line->eval(t => "0")))
        {
            return [ 1, 1, 0 ];

        } elsif ((ParametricLine("$line") == $linestu)
            && ($linestu->eval(t => $bstu) == $line->eval(t => "1")))
        {
            return [ 1, 0, 1 ];

        } elsif ((ParametricLine("$line") == $linestu)) {
            return [ 1, 0, 0 ];

        } else {
            return [ 0, 0, 0 ];
        }

    }
);

Setup

We create a MutiAnswer answer checker that will evaluate the students vector parametric equation at the starting and ending times provided by the student. For example, both of the student answers (4,0) + t<-4,2> for t between 0 and 1, and (4,0) + t<-2,1> for t between 0 and 2 will be marked correct.

BEGIN_PGML
Find a vector parametric equation for the line
segment from the point [`P = [$P]`]
to [`Q = [$Q]`].

[` \vec{r}(t) = `] [__]{$multians}

for
[__]{$multians}
[` \leq t \leq `]
[__]{$multians}
END_PGML

Statement

Since the three answer blanks depend on each other, we use $multians for each answer blank.

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.