Hi! How I can set solid x,y, z coordinate and temporary x, y, z coordinate?

12 views (last 30 days)
Hi! How I can set solid x,y, z coordinate and temporary x, y, z coordinate? Somehow like when the plane will be a side wall then the coordinate system will be from the side and then the z-axis will lie on the bottom of the cube. Please edit my question or let me know if it is really difficult to understand because I am not sure if I was able to explain my idea. I am trying to do it to save the position and direction of angle azimuth when the ray will reflect from other planes, not only from top as set by default. I have attached a picture, maybe it will be more useful.
Or maybe to apply indexation of planes. I have already done it, but I am not sure if helps me. I also
planes(:,:,1) = [0 3 3; 0 0 3; 0 3 0; 0 0 0; 0 0 0];
planes(:,:,2) = [0 0 3; 3 0 3; 0 0 0; 3 0 0; 0 0 0];
planes(:,:,3) = [3 0 3; 3 3 3; 3 0 0; 3 3 0; 3 0 0];
planes(:,:,4) = [3 3 3; 0 3 3; 3 3 0; 0 3 0; 0 3 3];
planes(:,:,5) = [0 3 0; 3 3 0; 0 0 0; 3 0 0; 0 0 0];
planes(:,:,6) = [0 3 3; 3 3 3; 0 0 3; 3 0 3; 0 0 3];
location_plane = 6;
for j=1:6 % j is number of plane
j
plane = planes(:,:,j);
p0 = plane(1,:); %p0 is top left point of plane
p1 = plane(2,:); %p1 is top right point of plane
p2 = plane(3,:); %p2 is bottom left point of plane
p3 = plane(4,:); %p3 is bottom right point of plane
V0 = plane(5,:); %point on the plane

Answers (1)

Karan Singh
Karan Singh on 23 Aug 2023
Hi Aknur, I believe what you are trying to achieve is rotation of the figure/ plot in directions to change its azimuthal angle. If this is what is required, then it can be set with a simple function view. Here is the link to its documentation Setting the Viewpoint with Azimuth and Elevation - MATLAB & Simulink (mathworks.com). refer the code below:
% Generate sample data
x = linspace(-5, 5, 100);
y = linspace(-5, 5, 100);
[X, Y] = meshgrid(x, y);
Z = sin(X) + cos(Y);
% Invert the x-coordinate to change to a left-handed coordinate system
X = -X;
% Create a 3D plot in the left-handed coordinate system
figure;
surf(X, Y, Z);
colorbar;
title('3D Plot in Left-Handed Coordinate System');
xlabel('X-axis');
ylabel('Y-axis');
zlabel('Z-axis');
The 3D plot created can be set for its viewing angle by adding
% Set the view to rotate 30 degrees to the right
view(30, 0);
% or
% Set the view to rotate 30 degrees to the top
view(0, 30);
This is for the viewing purpose and for what more I can infer from your description is that you have 3 axes of which 2 are right-handed while one is left-handed.
In MATLAB, you cannot directly change the handedness of the coordinate system. MATLAB assumes a right-handed coordinate system, where the positive x-axis points to the right, the positive y-axis points upward, and the positive z-axis points outward from the screen.
If you need to work with a left-handed coordinate system in MATLAB, you will need to manually adjust your data and transformations accordingly. This may involve flipping the sign of certain coordinates or applying appropriate transformations to align with the desired coordinate system.
For example, if you want to work with a left-handed coordinate system, you can invert the sign of the x-coordinate to reverse the direction of the x-axis. Here's an example:
% Generate sample data
x = linspace(-5, 5, 100);
y = linspace(-5, 5, 100);
[X, Y] = meshgrid(x, y);
Z = sin(X) + cos(Y);
% Invert the x-coordinate to change to a left-handed coordinate system
X = -X;
% Create a 3D plot in the left-handed coordinate system
figure;
surf(X, Y, Z);
colorbar;
title('3D Plot in Left-Handed Coordinate System');
xlabel('X-axis');
ylabel('Y-axis');
zlabel('Z-axis');
Hope it helps!

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!