Vectors in the plane

### 26.6.4 Vectors in the plane

See Section 27.4.4 for vectors in space.

The segment commands returns and draws vectors. (The segment command can also draw line segments, see section 26.6.3.)

- segment takes two arguments:
  - p, a point.
  - v, a vector.
- segment(p,v) returns the corresponding vector and draws it as a line segment from p to p+v.

#### Example

segment([-1,0],[1,1])

The vector command also makes vectors, with a different syntax. It can take its arguments in two different ways.

1. The coordinates of the vector.
   - vector takes L, a list of the coordinates of the vector.
   - vector(L) returns and draws the vector with the given coordinates, starting from the origin.
2. Two points or a point and a vector.
   - vector takes two arguments:
     - P, a point.
     - Q, a point or a vector. If Q is a point, it can be combined with P in a list.
   - vector(P,Q) returns and draws the corresponding vector. If the arguments are two points, the vector goes from P to Q. If the arguments are a point and a vector, then the vector starts at P.

#### Examples

vector([1,2])

vector([-1,0],[1,i])

or:

vector(-1,i)

or:

V:=vector(1,2+i):; vector(-1,V)