Reputation: 125
As part of an assignment related to graphics, I have to solve the simple equation Ax=b. In this equation, A is a known 2x3 matrix, b is a known 2x1 vector, and x is the unknown 3x1 vector, which has to be homogeneous.
Now, I know of the standard MATLAB solution x = A\b; However, this does not force x to be homogeneous. Is there a way I can force the third element of x to be 1?
Upvotes: 0
Views: 68
Reputation:
To force the third element of x to be 1, add an equation that says "x3=1". That is, add row [0 0 1]
to the matrix and corresponding entry 1
to the vector b
. Like this:
x = [A; 0 0 1] \ [b; 1]
A = [1 2 4; 3 4 5];
b = [6; 7];
Simply entering A\b
returns [-0.2857; 0; 1.5714]
.
But [A; 0 0 1] \ [b; 1]
returns [-2; 2; 1]
.
Upvotes: 1