The distance between objects in the plane: distance

### 13.14.2 The distance between objects in the plane: distance

See Section 14.12.7 for distances in three-dimensional geometry.

The distance command finds the distance between two geometric objects (a point is considered a geometric object).

- distance two arguments:
  G1,G2, two geometric objects.
- distance(G1,G2) returns the distance between G1 and G2.

#### Examples

- Input:
  distance(-1, 1+i)
  Output:

  √ |
  5

- Input:
  distance(0, line(-1,1+i))
  Output:

  √ |
  5
  5

- Input:
  distance(circle(0,1),line(-2,1+3*i))
  Output:

  √ |
  2
  | −1

Note that when the distance calculation uses parameters, Xcas must be in real mode.

#### Example

In real mode:
Input:

assumes(a=[4,0,5,0.1]); A:= point(0); B:= point(a);
simplify(distance(A,B)); simplify(distance(B,A))

Output:

⎪ ⎪ | a | ⎪ ⎪ | , | ⎪ ⎪ | a | ⎪ ⎪

In complex mode:
Input:

assumes(a=[4,0,5,0.1]); A:= point(0); B:= point(a);
simplify(distance(A,B)); simplify(distance(B,A))

Output:

−a, a

The distance command has distanceat and distanceatraw versions (see Section 13.14.1).