Calculate Rotation matrix from 3 points
Show older comments
I have 3 base coordinate points
p0 = [533,-422 -1];
px = [219 -57 -993];
py = [5 -70 -23];
I would like to calculate the transformation matrix above these points. How would I go about doing so? because I am quite lost...
Answers (2)
You can use this File Exchange submission,
but it is not enough to have 3 points. You need 3 points both before and after the transformation (actually only 2 if you are only estimating rotation and not translation).
A rotation in three dimensions has three degrees of freedom, so you need to know three "before" points and three "after" points.
I asssume you have given us the "after" points:
p0a = [533;-422;-1]; pxa = [219;-57;-993]; pya = [5;-70;-23];
I assume from the names of the ponts that the "before" points are
p0b=[0;0;0]; pxb=[1;0;0]; pyb=[0;1;0];
But those cannot be the real before points, because the "after" points are separated by more than 1 unit. Also, as @Matt J pointed out, the origin has been translated. You should check the "after" points to see that they form two equal-length legs of a right triangle. You may do this as follows:
fprintf('Length(pxa-p0a)=%.2f\n',norm(pxa-p0a));
fprintf('Length(pya-p0a)=%.2f\n',norm(pya-p0a));
fprintf('angle(pxa-p0a-pya)=%.2f radians\n',...
acos((pya-p0a)'*(pxa-p0a)/(norm(pya-p0a)*norm(pxa-p0a))));
We see that the sides are of unequal length and are not at right angles. Therefore you must reevaluate the original problem statement.
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!