Use exact parametric t values to clip a segment to a rectangular viewport.

Example

Clip a parametric line segment to a rectangular viewport.

highlighted = computed this step

Step 1 — Parametric line

Set up the exact input values.

A, B, B-A((0, 2), (6, 5), (6, 3))\begin{array}{c|c}\text{A, B, B-A}&\text{((0, 2), (6, 5), (6, 3))}\end{array}
Line clippingA segment is clipped against the rectangular viewport.AB

Step 2 — Entering t

Compute this boundary parameter.

t enter1/6\begin{array}{c|c}\text{t enter}&\hlmath{\text{1/6}}\end{array}
Line clippingA segment is clipped against the rectangular viewport.AB

Step 3 — Entering point

Compute the highlighted value.

enter point(1, 5/2)\begin{array}{c|c}\text{enter point}&\hlmath{\text{(1, 5/2)}}\end{array}
Line clippingA segment is clipped against the rectangular viewport.ABE

Step 4 — Exiting t

Compute this boundary parameter.

t exit2/3\begin{array}{c|c}\text{t exit}&\hlmath{\text{2/3}}\end{array}
Line clippingA segment is clipped against the rectangular viewport.ABE

Step 5 — Clipped segment

Compute the highlighted value.

clipped segment((1, 5/2), (4, 4))\begin{array}{c|c}\text{clipped segment}&\hlmath{\text{((1, 5/2), (4, 4))}}\end{array}
Line clippingA segment is clipped against the rectangular viewport.ABEX
line-clip-to-rectangle The same parametric segment equation from curves gives exact entering and exiting t values for clipping.