Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

Examples

Code Block
languagetext
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));

Additional information

Related commands

...