# Drawing a line: line

### 7.7.1 Drawing a line: line

The line command draws and finds lines in ℝ2 and ℝ3.

For a line in ℝ2:

- line takes one argument:
  eqn, a linear equation in the variables x and y.
- line(eqn) draws and returns the line given by the equation.

#### Examples.

- Input:
  line(2*y+x-1=0)
  Output:
- Input:
  line(y=1)
  Output:
- Input:
  line(x=1)
  Output:

For a line in ℝ3:

- line takes two arguments:
  eqn1 and eqn2, two linear equations in the variables x, y and z.
- line(eqn1,eqn2) draws and returns the line which is the intersection of the planes given by the equations.

#### Examples.

- Input:
  line(x+2*y+z-1=0,z=2)
  Output:
- Input:
  line(y=1,x=1)
  Output:

Remark
line defines an oriented line:

- When a 2D line is given by an equation, it is rewritten as lhs-rhs=ax+by+c=0, this determines its normal vector [a,b] and the orientation is given by the vector [b,−a].
- When a 3D line is given by two plane equations, its direction is defined by the cross product of the normals to the planes.

  When the plane equation is rewritten as lhs-rhs=ax+by+cz+d=0 the normal is [a,b,c]. For example, line(x=y,y=z) draws the line x−y=0,y−z=0 and its direction is:

  [1,−1,0]× [0,1,−1]=[1,1,1]