2
$\begingroup$

For didactic purposes I'd like to find an equation of the 3D-straight line passing through the origin and intersecting both 3D-straight lines $\{x-y+z-2=0, x-2 y+3 z-8=0\}$ and $\{y - z + 1 = 0 , x + y - 2 z + 4 = 0\}$.

I do it in such a way.

p1 = FindInstance[x - y + z - 2 == 0 && x - 2 y + 3 z - 8 == 0, {x, y, z}, Reals, 2];
L1 = InfiniteLine[Table[{x, y, z} /. p1[[j]], {j, 1, 2}]];
p2 = FindInstance[y - z + 1 == 0 && x + y - 2 z + 4 == 0, {x, y, z},Reals, 2];
L2 = InfiniteLine[Table[{x, y, z} /. p2[[j]], {j, 1, 2}]];

Now

Resolve[Exists[t, {a*t, b*t, c*t} \[Element] L1] && 
Exists[s, {a*s, b*s, c*s} \[Element] L2], Reals]

a - b != 0 && a - c != 0 && 3 a - 2 b + c == 0 && a - 3 b + 2 c == 0

FindInstance[a - b != 0 && a - c != 0 && 3 a - 2 b + c == 0 && 
a - 3 b + 2 c == 0, {a, b, c},Reals]

{{a -> 1, b -> 5, c -> 7}}

Therefore, the requested line is InfiniteLine[{0,0,0},{1,5,7}] and its parametric equations are {t,5*t,7*t}.

Is there a simpler and shorter way to do the job (The usage of a long formula from a thick handbook on analytical geometry is not allowed.)?

$\endgroup$
1
  • $\begingroup$ It should be noticed the above approach works if the given two lines are parallel (Then the solution may not exist and FindInstance in the latest command results in {},) and the given two lines intersect. One may try p1 = FindInstance[x - 2 == 0 && 3 z - 8 == 0, {x, y, z}, Reals, 2];p2 = FindInstance[x - 3 == 0 && 3 z - 8 == 0, {x, y, z}, Reals, 2]. $\endgroup$
    – user64494
    Nov 9, 2021 at 7:38

3 Answers 3

1
$\begingroup$

So we can solve for a parametric version of the first line

 l1 = ({x, y, z} /. Solve[{x - 2 == 0, 3 z - 8 == 0}, {x, y, z}] // First) /. {x -> s, y -> s, z -> s}
 (*   {2, s, 8/3}  *)

and the second line...

 l2 = ({x, y, z} /.Solve[{y - z + 1 == 0, x + y - 2 z + 4 == 0}, {x, y, z}] //  First) /. {x -> t, y -> t, z -> t}
 (*   {t, 2 + t, 3 + t}   *)

You also can potentially get a warning you can ignore...

  "Solve::svars: Equations may not give solutions for all "solve" variables."

Then find the values of $s$ and $t$ such that $l1(s)$ is in line with $l2(t)$ from the origin.

  res = Solve[l1 == α l2, {α, s, t}] // First 

 (*   {α -> 2/9, s -> 22/9, t -> 9}   *) 

Your line is then parameterized as...

 (l1 /. res) u
 (*   {2u, (22u)/9, (8u)/3}   *)
$\endgroup$
11
  • $\begingroup$ Something to adjust: res in last but one line is not defined. Also (l1 /. res)t is not grounded. Thank you anyway. $\endgroup$
    – user64494
    Nov 8, 2021 at 19:40
  • $\begingroup$ A more serious remark: your approach does not work for some lines, e.g. {x, y, z} /. Solve[{x - 2 == 0, 3 z - 8 == 0}, {y, z}] // First results in x,whereas the approach used by me works. It is not so simple. $\endgroup$
    – user64494
    Nov 8, 2021 at 19:52
  • $\begingroup$ In addition to the above: FindInstance[{x - 2 == 0, 3 z - 8 == 0}, {x, y, z}, Reals, 2] results in {{x -> 2, y -> 1/2, z -> 8/3}, {x -> 2, y -> 3/5, z -> 8/3}}. $\endgroup$
    – user64494
    Nov 8, 2021 at 20:05
  • $\begingroup$ I will be waiting for more qualified answers. Thank you again and again. $\endgroup$
    – user64494
    Nov 8, 2021 at 20:10
  • $\begingroup$ Yeah, it's not global, but the main idea of parameterizing the two lines then solving for those parameters and the scaling α holds. Best of luck! $\endgroup$
    – MikeY
    Nov 8, 2021 at 20:13
4
$\begingroup$

You can use implicit equations (as linear polynomials), with separate variables for each line. Augment with equations to force the vector from a point on one line to the origin, to be parallel to a vector from point on the other line to the origin. This gives equations that determine the two intersecting points. Augment further by having the vector from a point on the new line to one of these be parallel to the vector between same point on the new line and the other. These involve using two new variables to account for vectors being scalar multiples of one another. Last, compute a Groebner basis and eliminate all unwanted variables.

vars1 = {x1, y1, z1};
vars2 = {x2, y2, z2};
vars = {x, y, z};
polys = Flatten[{vars1 . {1, -1, 1} - 2, vars1 . {1, -2, 3} - 8, 
    vars2 . {0, 1, -1} + 1, vars2 . {1, 1, -2} + 4, 
    vars1 - s*vars2, (vars - vars1) - t*(vars - vars2)}];
GroebnerBasis[polys, vars, Join[vars1, vars2, {s, t}]]

(* Out[2270]= {7 y - 5 z, 7 x - z} *)
$\endgroup$
6
  • $\begingroup$ -1. The above is done rather by hand. Is that approach understandable for students? Thank you anyway. $\endgroup$
    – user64494
    Nov 9, 2021 at 6:55
  • $\begingroup$ Does your approach work if two given lines intersect? $\endgroup$
    – user64494
    Nov 9, 2021 at 7:19
  • 3
    $\begingroup$ @user64494 Words fail me. (Well, not really, I'm just not willing to put them into an MSE comment.) In any case this is the last response to any MSE question you will get from me. Your wackiness has finally exceeded my capacity. $\endgroup$ Nov 9, 2021 at 14:58
  • $\begingroup$ DanielLichblau (@does not work): I cancel my "-1". $\endgroup$
    – user64494
    Nov 10, 2021 at 13:00
  • $\begingroup$ Thank you. It is generally not good forum practice to punish people who offer assistance, even when they miss the mark. (Better to let other people punish them for that.) $\endgroup$ Nov 10, 2021 at 14:37
2
$\begingroup$

Edit

sol=FindInstance[
 t1*{x, y, z} ∈ 
   ImplicitRegion[
    x - y + z - 2 == 0 && x - 2 y + 3 z - 8 == 0, {x, y, z}] && 
  t2*{x, y, z} ∈ 
   ImplicitRegion[
    y - z + 1 == 0 && x + y - 2 z + 4 == 0, {x, y, z}], {t1, t2, x, y,
   z}, Reals]
{x, y, z} /. sol

{{-1, -5, -7}}

Original

reg1 = ParametricRegion[{t*{x, y, z}, 
    x - y + z - 2 == 0 && x - 2 y + 3 z - 8 == 0}, {x, y, z, t}];
reg2 = ParametricRegion[{t*{x, y, z}, 
    y - z + 1 == 0 && x + y - 2 z + 4 == 0}, {x, y, z, t}];
reg = RegionIntersection[reg1, reg2];
Simplify[RegionMember[reg][{x, y, z}], {x, y, z} ∈ Reals]
FindInstance[{x, y, z} ∈ reg, {x, y, z}, 1]
FindInstance[{x, y, z} ∈ reg, {x, y, z}, 2]

(x == 0 && y == 0 && z == 0) || (3 x + z == 2 y && x + 2 z == 3 y && (((2 x != y || x + 3 z != 2 y) && x != y) || x != z))

{{x -> 1/2, y -> 5/2, z -> 7/2}, {x -> 3/5, y -> 3, z -> 21/5}}

Show[Region[reg1, BaseStyle -> Cyan], 
 Region[reg2, BaseStyle -> Yellow], 
 Region[reg, BaseStyle -> {Thick, Red}]]

enter image description here

$\endgroup$
2
  • $\begingroup$ I don't find it simpler than mine. You consider parametric regions in four dimensions. However, a fresh approach.+1. $\endgroup$
    – user64494
    Nov 9, 2021 at 6:51
  • $\begingroup$ Nice solution approach $\endgroup$
    – MikeY
    Nov 9, 2021 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.