Exploring Analyic Geometry with Mathematica®

Home Contents Commands Packages Explorations Reference
Tour Lines Circles Conics Analysis Tangents

Line Segment Cut by Two Lines

lnlndist.html

Exploration

Let "lnlndist_1.gif" and "lnlndist_2.gif" be two intersecting lines and "lnlndist_3.gif" a point. Describe a procedure for finding the lines through "lnlndist_4.gif" such that "lnlndist_5.gif"and "lnlndist_6.gif" cut off a line segment of length S>0. Implement the solution as a Mathematica function.

Approach

Translate "lnlndist_7.gif" and "lnlndist_8.gif" so that their intersection point is at the origin.  "lnlndist_9.gif" and "lnlndist_10.gif" can then be written as "lnlndist_11.gif" and  "lnlndist_12.gif". The line "lnlndist_13.gif" through "lnlndist_14.gif" can then be written as "lnlndist_15.gif", since "lnlndist_16.gif" cannot pass through the origin. Since "lnlndist_17.gif" is on "lnlndist_18.gif", "lnlndist_19.gif". A second equation can be formed using the condition that the distance between the points of intersection of ("lnlndist_20.gif" and "lnlndist_21.gif") and ("lnlndist_22.gif" and "lnlndist_23.gif") must be S. Solve the two equations for "lnlndist_24.gif" and "lnlndist_25.gif". There are two or four solutions depending on the geometric configuration and the value of S. Translate the resulting solutions back to the original position.

Initialize

To initialize Descarta2D, select the input cell bracket and press SHIFT-Enter.

This initialization assumes that the Descarta2D software has been copied into one of the standard directories for AddOns which are on the Mathematica search path, $Path.

<<Descarta2D`

Solution

Special case first, the lines intersect at the origin. The equations are solved using NSolve to avoid complicated exact solutions.

Line2D[p0:Point2D[{x0_,y0_}],
       l1:Line2D[A1_,B1_,C1_ /; IsZero2D[C1]],
       l2:Line2D[A2_,B2_,C2_ /; IsZero2D[C2]],
       S_?IsScalar2D] :=
   Module[{L12,A12,B12,eq1,eq2,ans},
      eq1=Equation2D[L12=Line2D[A12,B12,1],{x0,y0}];
      eq2=Distance2D[Point2D[l1,L12],Point2D[l2,L12]]^2==S^2;
      ans=Select[NSolve[{eq1,eq2},{A12,B12}],
                 (Not[IsComplex2D[A12 /. #]] &&
                  Not[IsComplex2D[B12 /. #]])&];
      Map[(Line2D[A12,B12,1] /. #)&,ans] ] /;
Not[IsZeroOrNegative2D[S]] && Not[IsParallel2D[l1,l2]];

Here's the general case. It uses the special case for the core computation.

Line2D[p0:Point2D[{x0_,y0_}],
       l1:Line2D[A1_,B1_,C1_],
       l2:Line2D[A2_,B2_,C2_],
       S_?IsScalar2D] :=
   Module[{u,v,lns},
      {u,v}=Coordinates2D[Point2D[l1,l2]];
      lns=Line2D[Translate2D[p0,-{u,v}],
                 Translate2D[l1,-{u,v}],
                 Translate2D[l2,-{u,v}],S];
      Translate2D[lns,{u,v}] ] /;
Not[IsZeroOrNegative2D[S]] && Not[IsParallel2D[l1,l2]];

Discussion

Here's an example of the special case that has two solutions:

"lnlndist_26.gif" and "lnlndist_27.gif" with S=2 through the point (2,-1).

P0=Point2D[2,-1];
L1=Line2D[2,-3,0];
L2=Line2D[4,3,0];
L12=Line2D[P0,L1,L2,2]

"lnlndist_28.gif"

Sketch2D[{P0,L1,L2,L12}]

"lnlndist_29.gif"

Graphics saved as "lnlndi01.eps".

Here's an example of the general case that has four solutions:

"lnlndist_30.gif" and "lnlndist_31.gif" with S=4 through the point (-1,2).

P0=Point2D[1,2];
L1=Line2D[2,1,-2];
L2=Line2D[-1,3,-1];
L12=Line2D[P0,L1,L2,4]

"lnlndist_32.gif"

Sketch2D[{P0,L1,L2,L12}]

"lnlndist_33.gif"

Graphics saved as "lnlndi02.eps".


Copyright © 1999-2007 Donald L. Vossler, Descarta2D Publishing
www.Descarta2D.com