MATLAB Answers

How to convert the points with respect to co-ordinate system?

15 views (last 30 days)
I have huge three 90*85 matrices with x,y,z values calculated from the left upper corner of the matrix. I would like to change the points with respect to new coordinate system.
How can I convert the points? Do you need more explanation?


Roger Stafford
Roger Stafford on 30 Mar 2018
@Swapnil Rane: Yes, we do indeed need much more explanation. Aside from simply applying the conversion formulas from the current to the new coordinate systems for each triplet within the three respective matrices, what is it you are asking?
Also what is the significance of the phrase "calculated from the left upper corner"? What does it matter how these original values were calculated, with regard to the task of computing the necessary conversions?
Swapnil Rane
Swapnil Rane on 30 Mar 2018
I have imported a image to find the pixel values. As per my knowledge the location of (0,0) of the matrix in the left upper corner. But the local coordinate system is at the centre of the body. How can I create a transformation matrix? to convert all the points according to the new coordinate system

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 30 Mar 2018
Usually you would create a transformation matrix, either 3 x 3 or 4 x 4, and you would take the three matrices and reshape them and concatenate them to create columns of a vector, and then use matrix multiplication by the transformation matrix. Take the N x 3 or N x 4 matrix that results and reshape the columns back to the original size of your input matrices.


Show 1 older comment
Walter Roberson
Walter Roberson on 30 Mar 2018
x = randi([-5 5], 9, 8);
y = randi([-5 5], 9, 8);
z = randi([-5 5], 9, 8);
m = makehgtform('xrotate',pi/2,'yrotate',pi/2, 'scale', [1/2 2 1/3]);
xyz0 = [x(:), y(:), z(:), zeros(numel(x),1)];
newxyz0 = xyz0 * m;
newx = reshape(newxyz0(:,1), size(x));
newy = reshape(newxyz0(:,2), size(y));
newz = reshape(newxyz0(:,3), size(z));
Swapnil Rane
Swapnil Rane on 30 Mar 2018
Thank you for your answer. I really appreciate it. Could you tell me the transformation matrix for this case? This would will be very helpful
Walter Roberson
Walter Roberson on 30 Mar 2018
Just subtract off the location of the center from the coordinates.
x_center = mean(x(:));
y_center = mean(y(:));
z_center = mean(z(:));
newx = x - x_center;
newy = y - y_center;
newz = z - z_center;

Sign in to comment.

More Answers (1)

Abhishek Ballaney
Abhishek Ballaney on 30 Mar 2018

  1 Comment

Swapnil Rane
Swapnil Rane on 30 Mar 2018
I just want to transform the coordinate system and get the location of points according to new coordinate system

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!