Go to start of banner

# Description

Identifies the point on a vector closest to a line

`l1` and `l2` specify a line segment which goes through both points. This line segment is extended to be a line of infinite length. getPointClosestTo will orthogonally project `p` onto this line to return the point which is closest to `p` and `l1-l2`.

Note that the point returned can be outside of the line segment `l1-l2`.

Math

# Command syntax

## Syntax

 `getPointClosestTo vector1 vector2 vector3`

### Arguments

`vector1`vectoryesThe first endpoint of the vector which is constructed from vector1 and vector2
`vector2`vectoryesThe second endpoint of the vector which is constructed from vector1 and vector2
`vector3`vectoryesThe point in space for which the user wants to find the closest point on the line from vector1 and vector2

None

## Return value

vector

Returns a variable of type vector which is the point on the line  from vector1 and vector2 that is closest to vector3.

## Examples

`vector \$l1 = <<1, 0, 0>>;vector \$l2 = <<0, 1, 0>>;vector \$o = <<0, 0, 0>>; // l1 and l2 form a line of slope -1 in the X-Y plane// that goes through both points l1 and l2. o is the origin. // The point on the line closest to the origin is <<0.5, 0.5, 0>>print(getPointClosestTo(\$l1, \$l2, \$o)); // This example shows that you can get a point outside of the line// segment delineated by l1-l2 (the closest point to the line segment// would be l2, but the closest point to the line of infinite length// is <<-0.5, 1.5, 0>>)vector \$p = <<-1, 1, 0>>;print(getPointClosestTo(\$l1, \$l2, \$p));`