# Translational motion of a rotating object.

30 views (last 30 days)
Muhammad Mansoor Khan on 30 Dec 2019
Edited: Jim Riggs on 1 Jan 2020
Hello, I have written a code for the simulation of a rotating object. Can someone help me with a code for the translation of this system's center of mass, which will take a parabolic path. Which means in the final code the object will be rotating along with its center of mass moving in a parabolic path. I want to show this whole process as single simulation.
Your help will highly be appreciated.
clc;
clear;
w=5; % angular velocity
theta=0;
P=[0 0]; % P is position
dt=0.01; % dt= time step
for i=1:500
theta_n= theta(i) + w*(dt);
theta=[theta theta_n];
Pn=[cos(theta(i)) sin(theta(i))]; % Pn is next position
P=[P;Pn];
end
x=(P(:,1))';
y=(P(:,2))';
for i=1:500
plot(x(i),y(i),'ro')
axis([min(x) max(x) min(y) max(y)])
hold on
plot([0 x(i)], [0 y(i)])
hold off
%ylabel([min(w_til) max(w_til)])
pause(0.01)
end

Image Analyst on 31 Dec 2019
Try this:
w=5; % angular velocity
theta=0;
P=[0 0]; % P is position
dt=0.01; % dt= time step
for i=1:500
theta_n= theta(i) + w*(dt);
theta=[theta theta_n];
Pn=[cos(theta(i)) sin(theta(i))]; % Pn is next position
P=[P;Pn];
end
x=(P(:,1))';
y=(P(:,2))';
% Get the center of mass
numPoints = length(x);
xCenter = linspace(-1, 1, numPoints);
% Define where the yCenter is for each xCenter.
yCenter = xCenter .^2 + 2 * xCenter + 2;
plot(xCenter, yCenter, 'b-', 'LineWidth', 2);
grid on;
xc = x + xCenter;
yc = y + yCenter;
axis([min(xc) max(xc) min(yc) max(yc)])
hold on
for i=1:500
% Draw circle
plot(xc(i), yc(i),'ro')
% Draw line from origin.
% plot([0, xc(i)], [0, yc(i)])
plot([xCenter(i), xc(i)], [yCenter(i), yc(i)])
grid on;
drawnow;
% pause(0.01)
end
fprintf('Done!\n'); Jim Riggs on 31 Dec 2019
Edited: Jim Riggs on 1 Jan 2020
To begin, Chasles' theorem states that translational motion and rotational motion obey the law of superposition. Therefore, you can compute the rotation and translation separately and add them together. The best way to keep track of what you are doing is to draw a good picture, define reference frames and system parameters.
From your existing code, it apears that you are defining the position of point P based on a rotation angle, Theta. In the figure I have drawn, theta is measured relative to some body axis.
Now I am assuming that you want to add translation to this, so the location of the body axis is moving with respect to some other axis (let's call it the Inertial axis). To get the position of P in the inertial axis, you add the position in the Body axis (vector Pn) to the position of the body axis reference center in the inertial axis (vector Rc).
Since we are dealing with a point, the position Pn can be defined in body axes based on your rotational equations, and the position of the Body reference frame (Rc) can be defined based on the translational dynamics. You simply add Rc + Pn to get the position Rn in the Inertial fame.
Note that this vector addition must be performed using the same basis vectors on each vector. If the reference frames are defined such that the X-body axis is aligned with the X-inertial axis (likewise in the y-axis, as in my drawing) then this is achieved and you may perform the addition. 