
How to customize setting the included angle of the XY axis to 120 degrees?
3 ビュー (過去 30 日間)
古いコメントを表示
Hi, i am a PHD of chemistry. Considering that I need to build a structural model of the hexagonal crystal system, I need to set the angle between the XY axis to 120 degrees in the 3D drawing, while the Z axis remains perpendicular to the XY plane. What should I do? I would appreciate any advice you can provide!
0 件のコメント
回答 (1 件)
Ayush
2023 年 8 月 22 日
I understand that you want to set the angle between XY as 120 degree while keeping Z-axis perpendicular to XY plane. This can be achieved by performing coordinate transformation as given bellow:
% Generate a 3D coordinate system
figure;
quiver3(0, 0, 0, 1, 0, 0, 'r', 'LineWidth', 2); % X axis (red)
hold on;
quiver3(0, 0, 0, 0, 1, 0, 'g', 'LineWidth', 2); % Y axis (green)
quiver3(0, 0, 0, 0, 0, 1, 'b', 'LineWidth', 2); % Z axis (blue)
axis equal;
% Apply rotation transformation
angle = 120; % Angle in degrees
rotationMatrix = [cosd(angle) -sind(angle) 0; sind(angle) cosd(angle) 0; 0 0 1];
% Apply the rotation to the coordinate system
newXAxis = rotationMatrix * [1; 0; 0];
newYAxis = rotationMatrix * [0; 1; 0];
newZAxis = rotationMatrix * [0; 0; 1];
% Plot the rotated coordinate system
quiver3(0, 0, 0, newXAxis(1), newXAxis(2), newXAxis(3), 'r--', 'LineWidth', 2); % Rotated X axis (dashed red)
quiver3(0, 0, 0, newYAxis(1), newYAxis(2), newYAxis(3), 'g--', 'LineWidth', 2); % Rotated Y axis (dashed green)
quiver3(0, 0, 0, newZAxis(1), newZAxis(2), newZAxis(3), 'b--', 'LineWidth', 2); % Z axis (blue)

The rotated coordinate system is plotted using dashed lines. You can adjust the ‘angle’ variable to set the desired angle between XY axis. You may read further on ‘quiver3’ here: https://in.mathworks.com/help/matlab/ref/quiver3.html
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!