1
$\begingroup$

I would like to determine the point of intersection of a line which crosses a plane. If I were to do it by hand, I would proceed as follows:

  1. Find the parametric representation for line $r(t) = (x_0,y_0,z_0)$ $t(x_1-x_0, y_1-y_0,z_1-z_0)$
  2. Sub into the plane equation
  3. Solve for (t)
  4. Find point of intersection

How can I do this in Mathematica?

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – user9660 Apr 8 '15 at 14:05
  • $\begingroup$ Please add working code to make reproduction of your problem possible. Otherwise answering will be difficult. $\endgroup$ – user9660 Apr 8 '15 at 14:06
3
$\begingroup$

Example:

   planeEqn = 2 x - 3 y + 7 == 0;
   pt = {-1, 4, 2};
   dir = {3, 3, -1};
   r[t_] := pt + t dir

   t1 = t /. First@Solve[planeEqn /. Thread[{x, y, z} -> r[t]], t]
(* -7/3 *)
   r[t1]
(* {-8, -3, 13/3} *)
$\endgroup$
0
$\begingroup$
int[n_, pip_, p1_, p2_] := 
  p1 t + (1 - t) p2 /. First@Solve[(t p1 + (1 - t) p2).n == pip.n, t];
int2[{p1_, p2_, p3_}, {p4_, p5_}] := 
 int[Cross[p2 - p1, p3 - p1], p1, p4, p5]

With int, n is normal to plane and pip is point in plane, p1 and p2 define line. int2uses {p1,p2,p3} as three points in plane and {p4,p5} points defining the line. A line in the plane will return the line. When there is no intersection an error will be thrown. I leave it to interested party to correct (and clean to deal with degenerate specifications).

For fun (and to illustrate use of InfinitePlane,InfiniteLine,RegionIntersection):

DynamicModule[{r = RandomReal[{0, 5}, {2, 3}], 
  s = RandomReal[{0, 5}, {3, 3}]},
 Grid[{{Dynamic@Button["Line", r = RandomReal[{-5, 5}, {2, 3}]], 
    Dynamic@Row[{"r[t]=", Simplify[t r[[1]] + (1 - t) r[[2]] ]}]},
   {Dynamic@Button["Plane", s = RandomReal[{-5, 5}, {3, 3}]], 
    Dynamic[Simplify[
      Cross[s[[1]] - s[[2]], s[[1]] - s[[3]]].({x, y, z} - s[[1]]) == 
       0]]}, {Dynamic@
     Graphics3D[{InfinitePlane[s], {Blue, Thick, 
        InfiniteLine[r]}, {Red, PointSize[0.04], Point[int2[s, r]]}}, 
      PlotRange -> All, Boxed -> False, ImageSize -> Medium], 
    Dynamic[int2[s, r]]}
   , {"Region Intersection", 
    Dynamic@RegionIntersection[InfinitePlane[s], InfiniteLine[r]]}}, 
  Frame -> All]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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