Distance between objects in the plane

### 24.13.2 Distance between objects in the plane

See Section 25.10.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

distance(-1,1+i)

| √ |
5

distance(0,line(-1,1+i))

√ |
5
5

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

| √ |
2
| −1

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

#### Example

In real mode:

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

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

In complex mode:

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

−a, a |  |  |  |  |  |  |  |  |  |

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