The biggest trick here is to learn to use MATLAB! MATLAB is a vector & array language. So learn to use those capabilities.
First, a line can be defined parametrically by a point on the line, and a vector that gives the direction.
Line 1:
P1 = [3 1 -4];
V1 = [-1 2 3];
So any point on line 1 is given as
Likewise,
P2 = [9 4 5/3];
V2 = [-13 -4 -5/3];
And a point on this line is defined by
You claim that these lines have a common point of intersection. We can test that:
So, does Q lie on line 1? If it does, then we could compute the value of t as
(Q - P1)./V1
ans =
0.5 0.5 0.5
If Q lies on line 1, then I should expect to see THREE copies of the exact same value. So great, Q does lie on line 1. How about line 2?
(Q - P2)./V2
ans =
0.5 0.5 2.5
So in fact, Q does NOT lie on line 2, because I do not see three copies of the same value. (The trick I used will fail only when some element of V1 or V2 is exactly zero.)
Do the lines intersect at any point? Or are they non-intersecting? Ok, I can be lazy at times. I'll let MATLAB do the work here.
syms s t
st = solve(P1 + t*V1 == P2 + s*V2,s,t)
st =
struct with fields:
s: [0×1 sym]
t: [0×1 sym]
It is not hard to show by hand either, but the symbolic toolbox makes it soooo easy. The empty result tells us that no values of s and t solve the problem. If you want to show the lines do not intersect by hand, you need to think about what an intersection would require. For example, we can view the problem in terms of linear algebra as:
Now, we need to solve for the 2x1 vector st, such that
Since the matrix A is a 3x2 matrix, no exact solution will exist, unless this rank is 2:
rank([A,P1.'-P2.'])
ans =
3
So the lines are indeed skew and non-intersecting. Were V1 and V2 the same vector (or a simple multiple of each other) then the lines would be parallel. In this case of course, we again see no intersection exists.
So the very first premise of your question appears to be false, that the lines do intersect. But if the lines are indeed non-parallel and non-intersecting, then you cannot compute a plane that contains them.
Oh, one other point, V1 and V2 are indeed perpendicular vectors, so you got that right.
My guess is your biggest problem is the definition of your two lines. I think you have z written down wrong for line 2.
Finally, at the point where you will need to determine the plane equations, there are several tools that will work. I would suggest either null or cross as good tools here, rather than writing the cross product computations explicitly. But first, you need to resolve the issue I brought up.