Is rotation matrix for rotating a vector can take any value of angle?
o2 = [0, 0, 0]; % Origin
ain = [1, 0, 0]; % Initial vector
input_axis = [0, 0, 1]; % Axis of rotation (z-axis)
theta = deg2rad(25); % 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, theta) * (ain – o2)’ + o2′;
% Transpose to row vector for display
a_rotated = a_rotated’;
bin=[3,0,2];
o4=[3,0,-2];
output_axis=[1,0,0];
% Compute the rotated vector in terms of phi
syms phi;
rot_matrix_phi = rot_matrix(output_axis, phi);
bin_o4_rotated = rot_matrix_phi * (bin – o4)’ ;
bin_o4_rotated = bin_o4_rotated’; % Transpose to row vector for display
% Display the symbolic result
disp(‘Rotated bin-o4 in terms of phi:’);
% Display the result
disp(a_rotated)
disp(bin_o4_rotated);
o4o2=o4-o2;
disp(o4o2);
coupler=(o4o2+bin_o4_rotated-a_rotated);
display(coupler);
% 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);
%after this stepit is unable to solve for theta more than 91 deg or less than -91 deg
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,3.5));
%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);
%please consider that if i take theta(in bold) more than 91 deg or less than -91 deg instead of 25 then it is not giving me the output(means angles_deg),is it the problem with my code or rotation matrix?o2 = [0, 0, 0]; % Origin
ain = [1, 0, 0]; % Initial vector
input_axis = [0, 0, 1]; % Axis of rotation (z-axis)
theta = deg2rad(25); % 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, theta) * (ain – o2)’ + o2′;
% Transpose to row vector for display
a_rotated = a_rotated’;
bin=[3,0,2];
o4=[3,0,-2];
output_axis=[1,0,0];
% Compute the rotated vector in terms of phi
syms phi;
rot_matrix_phi = rot_matrix(output_axis, phi);
bin_o4_rotated = rot_matrix_phi * (bin – o4)’ ;
bin_o4_rotated = bin_o4_rotated’; % Transpose to row vector for display
% Display the symbolic result
disp(‘Rotated bin-o4 in terms of phi:’);
% Display the result
disp(a_rotated)
disp(bin_o4_rotated);
o4o2=o4-o2;
disp(o4o2);
coupler=(o4o2+bin_o4_rotated-a_rotated);
display(coupler);
% 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);
%after this stepit is unable to solve for theta more than 91 deg or less than -91 deg
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,3.5));
%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);
%please consider that if i take theta(in bold) more than 91 deg or less than -91 deg instead of 25 then it is not giving me the output(means angles_deg),is it the problem with my code or rotation matrix? o2 = [0, 0, 0]; % Origin
ain = [1, 0, 0]; % Initial vector
input_axis = [0, 0, 1]; % Axis of rotation (z-axis)
theta = deg2rad(25); % 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, theta) * (ain – o2)’ + o2′;
% Transpose to row vector for display
a_rotated = a_rotated’;
bin=[3,0,2];
o4=[3,0,-2];
output_axis=[1,0,0];
% Compute the rotated vector in terms of phi
syms phi;
rot_matrix_phi = rot_matrix(output_axis, phi);
bin_o4_rotated = rot_matrix_phi * (bin – o4)’ ;
bin_o4_rotated = bin_o4_rotated’; % Transpose to row vector for display
% Display the symbolic result
disp(‘Rotated bin-o4 in terms of phi:’);
% Display the result
disp(a_rotated)
disp(bin_o4_rotated);
o4o2=o4-o2;
disp(o4o2);
coupler=(o4o2+bin_o4_rotated-a_rotated);
display(coupler);
% 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);
%after this stepit is unable to solve for theta more than 91 deg or less than -91 deg
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,3.5));
%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);
%please consider that if i take theta(in bold) more than 91 deg or less than -91 deg instead of 25 then it is not giving me the output(means angles_deg),is it the problem with my code or rotation matrix? vector, rotation MATLAB Answers — New Questions