Rotate clouds of points

Hello!
I have one clouds of points, which are represented in 2D. I need one function that give me one new clouds of points if I have the following input parameters: an specific angle and distance applied to the initial clouds of points, so at the end, the new clouds of points have the same shape, but it stay shifted and rotated. Is there any function done in Matlab? Any idea??

1 件のコメント

Ashish Uthama
Ashish Uthama 2011 年 6 月 15 日
In what form do you have these points? x and y values? or a 2D matrix? How do you define the origin for the rotation?
Basic geometry: you could rotate them first by converting to polar coordinates (cart2pol) and then adding the angle. Convert back to cart (pol2cart) and just add the shift to the x and/or y values.

サインインしてコメントする。

回答 (1 件)

Ashish Uthama
Ashish Uthama 2011 年 6 月 15 日

0 投票

x=1:.01:2;
y=sin(2*pi*x);
plot(y,x,'k*');
hold on;
% rotate by 30 clockwise around (0,0)
% http://en.wikipedia.org/wiki/Rotation_matrix
rotAngle = deg2rad(30);
xRot = x*cos(rotAngle) - y*sin(rotAngle);
yRot = x*sin(rotAngle) + y*cos(rotAngle);
plot(yRot,xRot,'b*');
%and move by (3 2)
xRotShift = xRot + 3;
yRotShift = yRot + 5;
plot(yRotShift,xRotShift,'r*');

3 件のコメント

ana
ana 2011 年 6 月 15 日
Firstly, thanks for your answer!!
The problem is that the origin of the rotation is the center of gravity of my cloud of points (2D matrix). So in this case, I should apply one translation of point to origin, the rotation about origin and after the translation of origin to point, right?
Ashish Uthama
Ashish Uthama 2011 年 6 月 17 日
yes.
haishan zhu
haishan zhu 2017 年 8 月 30 日
how about 3 dimension condinates? thank you

サインインしてコメントする。

カテゴリ

質問済み:

ana
2011 年 6 月 15 日

コメント済み:

2017 年 8 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by