You do this via the "extract" method:
$V = Vector("<1,2>"); $x = $V->extract(1); $y = $V->extract(2);
This only works for constant vectors, however, not vector formulas
(since the formula could be produced from a cross product or something
so that it would not be straight-forward to obtain the coordinates
separately). If you are interested in COMPUTING the value rather than
displaying the formula, however, you could use dot products to obtain
the value. For example,
$V = Vector("<1,x>"); $x = $V . Vector(1,0); $y = $V . Vector(0,1);
will make $x and $y be formulas that
compute the first and second coordinates. (Note that you can give
vectors by lists of coordinates rather than strings, and you can even
do $V = Vector(1,"x") .) Of course, this would also work for constant vectors as well as formula vectors.
Alternatively, you could get both coordinates of a constant vector at once,
$V = Vector("<1,2>"); ($x,$y) = $V->value;
since the "value" method returns an array of coordinates.
Davide
<| Post or View Comments |>
|