0
$\begingroup$

I have tried to write a code to check whether a line is parallel to the plane in Mathematica. Using that a plane has the normal vector of $\vec{n}=(a,b,c)$ and a line has a direction vector $\vec{L}=(l,m,n),$ the condition is $\vec{n}\cdot\vec{L} = a \,l + b \, m + c \, n = 0$. I have tried writing the following code:

{a, b, c, d} = {1, 2, 3, 4};
plane = ImplicitRegion[a x + b y + c z + d == 0, {x, y, z}];
{x0 , y0 ,z0} = {2, 1, 4}; 
{l , m , n} = {3, 1, 9};
line = ImplicitRegion[(x-x0)/l==(y-y0)/m==(z-z0)/n , {x,y,z}];
If[(al + bm +cn == 0),Return("parallel"),Return("not parallel")];

However, it doesn't seem to work. What are the mistakes?

$\endgroup$
  • 1
    $\begingroup$ al is a single symbol; if you want to multiply a and l you use a*l or a l. Also, don't use Return unless you know what it's for; then, use it with square brackets Return[...] instead of round brackets. $\endgroup$ – Roman Apr 17 at 17:10
1
$\begingroup$

You can give vector-values to variables and use scalar products:

planenormal = {1, 2, 3};
linedirection = {3, 1, 9};
planenormal.linedirection == 0

False

$\endgroup$
1
$\begingroup$

You could use RegionDisjoint:

RegionDisjoint[plane, line]

False

$\endgroup$
0
$\begingroup$
{a, b, c, d} = {1, 2, 3, 4};

plane = ImplicitRegion[a x + b y + c z + d == 0, {x, y, z}];

{x0, y0, z0} = {2, 1, 4};

{l, m, n} = {3, 1, 9};

line = ImplicitRegion[(x - x0)/l == (y - y0)/m == (z - z0)/n, {x, y, 
z}];

If[(a*l + b*m + c*n == 0), Return["parallel"], 
Return["not parallel"]];

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.