MATLAB Answers

change centre of revolution

2 views (last 30 days)
AYUSH SINGHAL
AYUSH SINGHAL on 16 Mar 2020
Answered: Payas Bahade on 18 Mar 2020
This is the surface i got when i rotated my 2D curve about origin.
But i want to ratate it about a specific point (7.5) on x axis.
i have attached the code, please help.
u0(1,1,1) = 2256.250;
u0(2,1,1) = 2256.250;
u0(3,1,1) = 2256.250;
u0(4,1,1) = 2256.250;
u0(5,1,1) = 2256.250; %1
u0(6,1,1) = 2256.250;
u0(7,1,1) = 2256.250;
u0(8,1,1) = 2256.250;
u0(9,1,1) = 2256.250;
u0(10,1,1) = 2256.250; %2
u0(11,1,1) = 2256.250;
u0(12,1,1) = 2256.250;
u0(13,1,1) = 2256.250;
u0(14,1,1) = 2256.250;
u0(15,1,1) = 2256.250; %3
u0(16,1,1) = 2256.250;
u0(17,1,1) = 2256.250;
u0(18,1,1) = 2256.250;
u0(19,1,1) = 2256.250;
u0(20,1,1) = 2256.250; %4
u0(21,1,1) = 2256.250;
u0(22,1,1) = 2256.250;
u0(23,1,1) = 2256.250;
u0(24,1,1) = 2256.250;
u0(25,1,1) = 2256.250; %5
u0(26,1,1) = 2256.25;
u0(27,1,1) = 2256.25;
u0(28,1,1) = 2256.2502;
u0(29,1,1) = 2256.2505;
u0(30,1,1) = 2256.251; %6
u0(31,1,1) = 2256.252;
u0(32,1,1) = 2256.253;
u0(33,1,1) = 2256.2528;
u0(34,1,1) = 2256.2522;
u0(35,1,1) = 2256.2525; %7
u0(36,1,1) = 2256.2530;
u0(37,1,1) = 2256.2540;
u0(38,1,1) = 2256.2540;
u0(39,1,1) = 2256.2538;
u0(40,1,1) = 2256.2530; %8
u0(41,1,1) = 2256.2521;
u0(42,1,1) = 2256.2530;
u0(43,1,1) = 2256.2531;
u0(44,1,1) = 2256.2530;
u0(45,1,1) = 2256.2512; %9
u0(46,1,1) = 2256.2501;
u0(47,1,1) = 2256.25;
u0(48,1,1) = 2256.25;
u0(49,1,1) = 2256.25;
u0(50,1,1) = 2256.25; %10
u0(51,1,1) = 2256.25;
u0(52,1,1) = 2256.25;
u0(53,1,1) = 2256.25;
u0(54,1,1) = 2256.25;
u0(55,1,1) = 2256.25; %11
u0(56,1,1) = 2256.25;
u0(57,1,1) = 2256.25;
u0(58,1,1) = 2256.25;
u0(59,1,1) = 2256.25;
u0(60,1,1) = 2256.25; %12
u0(61,1,1) = 2256.25;
u0(62,1,1) = 2256.25;
u0(63,1,1) = 2256.25;
u0(64,1,1) = 2256.25;
u0(65,1,1) = 2256.25; %13
u0(66,1,1) = 2256.25;
u0(67,1,1) = 2256.25;
u0(68,1,1) = 2256.25;
u0(69,1,1) = 2256.25;
u0(70,1,1) = 2256.25; %14
u0(71,1,1) = 2256.25;
u0(72,1,1) = 2256.25;
u0(73,1,1) = 2256.25;
u0(74,1,1) = 2256.25;
u0(75,1,1) = 2256.25; %15
N = 75;
x = [0:0.2:14.8]';
y = [0:0.2:14.8]';
z = u0';
figure()
hold on
revolves = 100;
theta = linspace(0,2*pi,revolves);
xx = zeros(revolves,N);
yy = xx;
zz = xx;
for idx = 1:length(theta);
xrot = cos(theta(idx))*x + sin(theta(idx))*y;
yrot = -sin(theta(idx))*x + cos(theta(idx))*y;
plot3(xrot,yrot,z)
xx(idx,:)=xrot;
yy(idx,:)=yrot;
zz(idx,:)=z;
end
grid on
surf(xx,yy,zz)
  1 Comment
darova
darova on 16 Mar 2020
Is this correct?

Sign in to comment.

Answers (1)

Payas Bahade
Payas Bahade on 18 Mar 2020
Hi Ayush,
To change x-coordinate of center of revolution to 7.5, add 7.5 to the xrot equation. The new equation becomes:
xrot = 7.5+cos(theta(idx))*x + sin(theta(idx))*y;
Replace current xrot equation in for loop with above one to get required results.
Hope this helps!

Community Treasure Hunt

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

Start Hunting!