# Synopsis

PDX_MSGT mth_Intersect3DLines(long option, double para_tol, double *pt1, double *tan1, double *pt2, double *tan2, double *alf1, double *alf2, double *intpt)

# Purpose

Solves for two straight lines in 3D space (least squares).

# Description

This routine solves the equations of two straight lines in 3D space by the method of least squares. The lines must be in point/vector form. The lines may or may not intersect. If they do not intersect, the solution represents the minimum distance between the two lines.

# Input

## option

### MTH_INTERSECT

If set, then the lines are assumed to intersect. The solution will then be computed as the solution to equation 2 (fastest method if the lines are known to intersect).

### MTH_ALPHAS

Just compute alf1 and alf2 (see below).

### MTH_POINT

Just compute the point. If MTH_INTERSECT is set, this is the solution point on line 2; if it is not set, then it is the midpoint of the shortest line segment connecting the two lines.

## para_tol

The parallel lines test tolerance.

## pt1

The initial point on the first line.

## tan1

The tangent vector of the first line.

## pt2

The initial point on the second line.

## tan2

The tangent vector of the second line.

# Output

## alf1

Parametric solution to equation 1 (see option). ( option must be set to MTH_ALPHAS )

## alf2

Parametric solution to equation 2 (see option). ( option must be set to MTH_ALPHAS )

## intpt

The intersection point of the two lines if they intersect. If they don't, then intpt is the midpoint of the shortest line segment connecting the two lines (see option). ( option must be set to MTH_POINT )

# Return

          MTH_NOERR
          MTH_PARALLELLINES
          .fi