How to vary angles at constant rate in a kinematics problem?
o2 = [0, 0, 0]; % Origin
ain = [26,0,0]; % Initial vector
input_axis = [0,1,0]; % Axis of rotation (z-axis)
theta1 = deg2rad(157.5); % Angle of rotation in radians
% Rotation matrix function
rot_matrix = @(axis, theta) cos(theta) * eye(3) + …
sin(theta) * [0, -axis(3), axis(2); axis(3), 0, -axis(1); -axis(2), axis(1), 0] + …
(1 – cos(theta)) * (axis’ * axis);
% Compute the rotated vector
a_rotated = rot_matrix(input_axis, theta1) * (ain’ – o2′) + o2′;
% Transpose to row vector for display
a_rotated = a_rotated’;
a_final=a_rotated;
bin=[29.5,46,0];
o4=[13.5,46,0];
output_axis=[0,1,0];
theta2= deg2rad(105);
b1_rotated = rot_matrix(output_axis, theta2) * (bin’ – o4′) + o4′;
b1_final=b1_rotated’;
u3=[0,0,1];
c1=[125,0,0];
% Compute the rotated vector in terms of phi
syms phi;
rot_matrix_phi = rot_matrix(u3, phi);
c1_afinal_rotated = rot_matrix_phi * (c1 – a_final)’+a_final’ ;
c1_afinal_rotated = c1_afinal_rotated’; % Transpose to row vector for display
o4o2=o4-o2;
%disp(o4o2);
coupler=(c1_afinal_rotated-b1_final);
% Define the initial rotated components of the coupler
syms phi;
coupler = subs(coupler, conj(phi), phi);
%disp(‘Coupler vector without conjugate:’);
disp(coupler);
% Parametric substitution
syms t;
cos_phi = (1 – t^2) / (1 + t^2);
sin_phi = 2 * t / (1 + t^2);
% Substitute parametric forms into coupler components
coupler_parametric = subs(coupler, [cos(phi), sin(phi)], [cos_phi, sin_phi]);
% Display the parametric coupler
disp(‘Parametric form of coupler:’);
disp(coupler_parametric);
syms targetvalue % it might be 3.5 …
normsq = expand(sum(coupler_parametric.^2) – targetvalue^2);
normpoly = simplify(normsq*(t^2+1)^2);
vpa(expand(normpoly),4);
tsolve = solve(normpoly,t,’maxdegree’,4,’returnconditions’,true);
h=vpa(subs(tsolve.t,targetvalue, 106));
%disp(h);
real_solutions = h(imag(h) == 0);
disp(‘Real roots:’);
disp(real_solutions);
% Convert real values of t to angles using angle = 2 * atan(t)
angles_rad = 2 * atan(real_solutions);
angles_deg = rad2deg(angles_rad);
% Display angles in degrees
disp(‘Angles in degrees before adjustment:’);
disp(angles_deg);
phi=double(angles_rad(1));
p=double(angles_deg(1));
c1_position = double(rot_matrix(u3, phi) * (c1′ – a_final’) + a_final’);
p=(c1_position’-a_final)’;
disp(p’);
disp(p(2)/norm(c1_position’-a_final));
final_angle_phi=acosd(p(2)/norm(c1_position’-a_final)); % angle with y axis
disp(final_angle_phi) ;
disp(norm(c1_position’-b1_final));
disp(norm(a_rotated-o2));
%% in this code i want to change theta1 at rate of 90deg/sec and theta2 at rate of 60 deg/sec varying from 0 to 360 deg and want to calculate corresponding value of final_angle_phi with the y axis
%please help someoneo2 = [0, 0, 0]; % Origin
ain = [26,0,0]; % Initial vector
input_axis = [0,1,0]; % Axis of rotation (z-axis)
theta1 = deg2rad(157.5); % Angle of rotation in radians
% Rotation matrix function
rot_matrix = @(axis, theta) cos(theta) * eye(3) + …
sin(theta) * [0, -axis(3), axis(2); axis(3), 0, -axis(1); -axis(2), axis(1), 0] + …
(1 – cos(theta)) * (axis’ * axis);
% Compute the rotated vector
a_rotated = rot_matrix(input_axis, theta1) * (ain’ – o2′) + o2′;
% Transpose to row vector for display
a_rotated = a_rotated’;
a_final=a_rotated;
bin=[29.5,46,0];
o4=[13.5,46,0];
output_axis=[0,1,0];
theta2= deg2rad(105);
b1_rotated = rot_matrix(output_axis, theta2) * (bin’ – o4′) + o4′;
b1_final=b1_rotated’;
u3=[0,0,1];
c1=[125,0,0];
% Compute the rotated vector in terms of phi
syms phi;
rot_matrix_phi = rot_matrix(u3, phi);
c1_afinal_rotated = rot_matrix_phi * (c1 – a_final)’+a_final’ ;
c1_afinal_rotated = c1_afinal_rotated’; % Transpose to row vector for display
o4o2=o4-o2;
%disp(o4o2);
coupler=(c1_afinal_rotated-b1_final);
% Define the initial rotated components of the coupler
syms phi;
coupler = subs(coupler, conj(phi), phi);
%disp(‘Coupler vector without conjugate:’);
disp(coupler);
% Parametric substitution
syms t;
cos_phi = (1 – t^2) / (1 + t^2);
sin_phi = 2 * t / (1 + t^2);
% Substitute parametric forms into coupler components
coupler_parametric = subs(coupler, [cos(phi), sin(phi)], [cos_phi, sin_phi]);
% Display the parametric coupler
disp(‘Parametric form of coupler:’);
disp(coupler_parametric);
syms targetvalue % it might be 3.5 …
normsq = expand(sum(coupler_parametric.^2) – targetvalue^2);
normpoly = simplify(normsq*(t^2+1)^2);
vpa(expand(normpoly),4);
tsolve = solve(normpoly,t,’maxdegree’,4,’returnconditions’,true);
h=vpa(subs(tsolve.t,targetvalue, 106));
%disp(h);
real_solutions = h(imag(h) == 0);
disp(‘Real roots:’);
disp(real_solutions);
% Convert real values of t to angles using angle = 2 * atan(t)
angles_rad = 2 * atan(real_solutions);
angles_deg = rad2deg(angles_rad);
% Display angles in degrees
disp(‘Angles in degrees before adjustment:’);
disp(angles_deg);
phi=double(angles_rad(1));
p=double(angles_deg(1));
c1_position = double(rot_matrix(u3, phi) * (c1′ – a_final’) + a_final’);
p=(c1_position’-a_final)’;
disp(p’);
disp(p(2)/norm(c1_position’-a_final));
final_angle_phi=acosd(p(2)/norm(c1_position’-a_final)); % angle with y axis
disp(final_angle_phi) ;
disp(norm(c1_position’-b1_final));
disp(norm(a_rotated-o2));
%% in this code i want to change theta1 at rate of 90deg/sec and theta2 at rate of 60 deg/sec varying from 0 to 360 deg and want to calculate corresponding value of final_angle_phi with the y axis
%please help someone o2 = [0, 0, 0]; % Origin
ain = [26,0,0]; % Initial vector
input_axis = [0,1,0]; % Axis of rotation (z-axis)
theta1 = deg2rad(157.5); % Angle of rotation in radians
% Rotation matrix function
rot_matrix = @(axis, theta) cos(theta) * eye(3) + …
sin(theta) * [0, -axis(3), axis(2); axis(3), 0, -axis(1); -axis(2), axis(1), 0] + …
(1 – cos(theta)) * (axis’ * axis);
% Compute the rotated vector
a_rotated = rot_matrix(input_axis, theta1) * (ain’ – o2′) + o2′;
% Transpose to row vector for display
a_rotated = a_rotated’;
a_final=a_rotated;
bin=[29.5,46,0];
o4=[13.5,46,0];
output_axis=[0,1,0];
theta2= deg2rad(105);
b1_rotated = rot_matrix(output_axis, theta2) * (bin’ – o4′) + o4′;
b1_final=b1_rotated’;
u3=[0,0,1];
c1=[125,0,0];
% Compute the rotated vector in terms of phi
syms phi;
rot_matrix_phi = rot_matrix(u3, phi);
c1_afinal_rotated = rot_matrix_phi * (c1 – a_final)’+a_final’ ;
c1_afinal_rotated = c1_afinal_rotated’; % Transpose to row vector for display
o4o2=o4-o2;
%disp(o4o2);
coupler=(c1_afinal_rotated-b1_final);
% Define the initial rotated components of the coupler
syms phi;
coupler = subs(coupler, conj(phi), phi);
%disp(‘Coupler vector without conjugate:’);
disp(coupler);
% Parametric substitution
syms t;
cos_phi = (1 – t^2) / (1 + t^2);
sin_phi = 2 * t / (1 + t^2);
% Substitute parametric forms into coupler components
coupler_parametric = subs(coupler, [cos(phi), sin(phi)], [cos_phi, sin_phi]);
% Display the parametric coupler
disp(‘Parametric form of coupler:’);
disp(coupler_parametric);
syms targetvalue % it might be 3.5 …
normsq = expand(sum(coupler_parametric.^2) – targetvalue^2);
normpoly = simplify(normsq*(t^2+1)^2);
vpa(expand(normpoly),4);
tsolve = solve(normpoly,t,’maxdegree’,4,’returnconditions’,true);
h=vpa(subs(tsolve.t,targetvalue, 106));
%disp(h);
real_solutions = h(imag(h) == 0);
disp(‘Real roots:’);
disp(real_solutions);
% Convert real values of t to angles using angle = 2 * atan(t)
angles_rad = 2 * atan(real_solutions);
angles_deg = rad2deg(angles_rad);
% Display angles in degrees
disp(‘Angles in degrees before adjustment:’);
disp(angles_deg);
phi=double(angles_rad(1));
p=double(angles_deg(1));
c1_position = double(rot_matrix(u3, phi) * (c1′ – a_final’) + a_final’);
p=(c1_position’-a_final)’;
disp(p’);
disp(p(2)/norm(c1_position’-a_final));
final_angle_phi=acosd(p(2)/norm(c1_position’-a_final)); % angle with y axis
disp(final_angle_phi) ;
disp(norm(c1_position’-b1_final));
disp(norm(a_rotated-o2));
%% in this code i want to change theta1 at rate of 90deg/sec and theta2 at rate of 60 deg/sec varying from 0 to 360 deg and want to calculate corresponding value of final_angle_phi with the y axis
%please help someone #angles, #omega MATLAB Answers — New Questions