### 12.4.4 Find the intersection points of two objects in space: inter

See section 11.6.6 for points of intersection of objects in the plane.

The inter command takes two geometric objects as arguments and returns a list of the points of intersection or the curve of intersection of the two objects.

The inter command optionally takes a point as a third argument. In this case, inter returns the point of intersection closest to this argument.

Input:

LA:=inter(plane(point(0,1,1),point(1,0,1),point(1,1,0)),
line(point(0,0,0),point(1,1,1)))

then:

coordinates(LA)

Output:

[[2/3,2/3,2/3]]

Input:

LB:=inter(sphere(point(0,0,0),1),line(point(0,0,0),point(1,1,1)))

then:

coordinates(LB)

Output:

[[1/sqrt(3),1/sqrt(3),1/sqrt(3)],[-1/sqrt(3),-1/sqrt(3),-1/sqrt(3)]]

To get just one of the points, use the usual list indices.
Input:

coordinates(LB[0])

Output:

[1/sqrt(3),1/sqrt(3),1/sqrt(3)]

To get the point closest to (1/2,1/2,1/2), enter
Input:

LB1:=inter(sphere(point(0,0,0),1),
line(point(0,0,0),point(1,1,1)),point(1/2,1/2,1/2))

then:

coordinates(LB1)

Output:

[1/sqrt(3),1/sqrt(3),1/sqrt(3)]