How to rotate a line?
Show older comments
Is there a way to rotate a line of 30 degree? For example: x=1; y=[2 4 6 8 10];
Does it require a center point of rotation?(example center point is [2,6])Or does it requires the center of the line?
Thanks.
Accepted Answer
More Answers (1)
Kevin Moerman
on 8 Feb 2012
Correct, and instead of E(3) just use a_rad straight away. Also if you find this too complex you could use POL2CART instead (make sure you understand the coordinate system transformation e.g. what is the positive direction etc):
x=-1:0.1:1; y=x; a=30; a_rad=((a*pi)./180);
[THETA,R] = cart2pol(x,y); %Convert to polar coordinates
THETA=THETA+a_rad; %Add a_rad to theta
[xr,yr] = pol2cart(THETA,R); %Convert back to Cartesian coordinates
plot(x,y,'g-'); hold on; %Original
plot(xr,yr,'b-'); axis equal; %Rotated
Kevin
Categories
Find more on Gravitation, Cosmology & Astrophysics 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!