Hi, I have a question, I have a table with 12 reference points
if true % POINT X Y Z 1 0 0 0 2 70.5 0 0 3 141 0 0 4 141 0 141.5 5 70.5 0 141.5 6 0 0 141.5 7 0 137.5 0 8 70.5 137.5 0 9 141 140 0 10 141 141.5 141.5 11 70.5 139 141.5 12 0 141.5 141.5 end
The segment 1 is defined by the point 1 and point 2 and the segment 2 is defined by the point 1 and point 7. I am able to calculate the angle with the following rotine,
if true % angle_x1_x13 = atan2(norm(cross(v1,v2)),dot(v1,v2)); anglout = radtodeg(angle_x1_x13); end
The result is ~90º and this result is correct if I think in xy plan, but I need to calculate the angle to yz plan and xz plan. Anyone help me?
To calculate angles between two segments in different planes (xyxy, yzyz, xzxz), you need to project the segments onto the respective plane and then compute the angle.
Extract Segment Vectors:
Project Vectors onto Each Plane:
Calculate the Angles:
Here's the MATLAB implementation:
% Define points points = [ 0, 0, 0; % Point 1 70.5, 0, 0; % Point 2 0, 137.5, 0; % Point 7 ]; % Extract vectors for segments P1 = points(1, :); P2 = points(2, :); P7 = points(3, :); v1 = P2 - P1; % Segment 1: P1 -> P2 v2 = P7 - P1; % Segment 2: P1 -> P7 % Project vectors onto XY, YZ, and XZ planes v1_xy = [v1(1), v1(2), 0]; v2_xy = [v2(1), v2(2), 0]; v1_yz = [0, v1(2), v1(3)]; v2_yz = [0, v2(2), v2(3)]; v1_xz = [v1(1), 0, v1(3)]; v2_xz = [v2(1), 0, v2(3)]; % Calculate angles in each plane angle_xy = atan2d(norm(cross(v1_xy, v2_xy)), dot(v1_xy, v2_xy)); angle_yz = atan2d(norm(cross(v1_yz, v2_yz)), dot(v1_yz, v2_yz)); angle_xz = atan2d(norm(cross(v1_xz, v2_xz)), dot(v1_xz, v2_xz)); % Display results fprintf('Angle in XY plane: %.2f degrees\n', angle_xy); fprintf('Angle in YZ plane: %.2f degrees\n', angle_yz); fprintf('Angle in XZ plane: %.2f degrees\n', angle_xz);
This will give you the angles between the segments in each of the specified planes. Let me know if you have further questions!
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.