MATLAB Answers

How to find rotation matrix from 4 rectangle points

39 views (last 30 days)
SOONMYUN JANG
SOONMYUN JANG on 30 May 2020
Commented: Image Analyst on 3 Jun 2020 at 15:11
Hi,
I have 4 3d points(x, y, z). Using these points how can I calculate rotation angle? Consequently, I want to have a 4x4 transformation matrix including rotation and translation information.
4 points are in a plane and they are corners of rectangle and I set the top-left point as the origin of the rectangle coordinate. Look at the bellow pictures.
Here I only have four 3D points(Xw,Tw,Zw) based on the world coordinate. According to the 4 points, I can calculate 4 points based on the rectangle coordinate. For instance, value [Xr] in P2 is the distance between P1 and P2. And [-Yr] in P3 is the distance between P1 and P3.
Then how could I get rotation angle of the rectangle based on the world coordinate using those information?
Additional information (3d points in the world coordinate):
P1(-401.428, 485.929, 772.921)
P2(-21.4433, 475.611, 772.511)
P3(-400.982, 483.56, 403.703)
P4(-21.589, 473.028, 403.242)

  0 Comments

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 30 May 2020
Wouldn't the rotation matrix be
rotMatrix = pDistorted \ pStraight

  4 Comments

Show 1 older comment
Image Analyst
Image Analyst on 2 Jun 2020 at 14:12
OK, I got this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 18;
fprintf('Beginning to run %s.m ...\n', mfilename);
P1 = [-401.428, 485.929, 772.921]
P2 = [-21.4433, 475.611, 772.511]
P3 = [-400.982, 483.56, 403.703]
P4 = [-21.589, 473.028, 403.242]
xyz = [P1;P2;P4;P3; P1]
x = xyz(:, 1);
y = xyz(:, 2);
z = xyz(:, 3);
plot3(x, y, z, 'b.-', 'MarkerSize', 30);
grid on;
xlabel('x', 'FontSize', fontSize);
ylabel('y', 'FontSize', fontSize);
zlabel('z', 'FontSize', fontSize);
but what do you want your transformed data coordinates to be?
SOONMYUN JANG
SOONMYUN JANG on 3 Jun 2020 at 10:29
I want to get a rotation information such as 3x3 rotation matrix.
Image Analyst
Image Analyst on 3 Jun 2020 at 15:11
Again: "what do you want your transformed data coordinates to be?" You gave only input coordinates, not output coordinates.

Sign in to comment.