multiple 3D plane plotting
Hi I have the following code to plot a 2D plane in 3D space.
the plane is describe by their dip angle and azimuth and the center point is at [x,y] = [0,0]
I intend to modify this code so that it can plot 3 planes in the same axis. However, the location for each plane will be varies depending on the x and y location.
planedip = 30;
planeazim = 120;
% Convert angles to radians
dip_angle_rad = deg2rad(planedip);
dip_azimuth_rad = deg2rad(360 – planeazim); % rotate from CCW to CW
% Define normal vector of plane
normal = [sin(dip_angle_rad)*cos(dip_azimuth_rad), sin(dip_angle_rad)*sin(dip_azimuth_rad), cos(dip_angle_rad)];
% Define two vectors in plane
v1 = [1, 0, (-normal(1)/normal(3))];
v2 = cross(normal, v1);
% Plot plane
x = linspace(-1,1,10);
y = linspace(-1,1,10);
[X,Y] = meshgrid(x,y);
Z = (-normal(1)*X – normal(2)*Y)/normal(3);
surf(X,Y,Z,’FaceColor’,[0.5,0.5,0.5],’FaceAlpha’,0.5,’EdgeColor’,’none’);
% Add annotations
hold on
quiver3(0, 0, 0, normal(1), normal(2), normal(3));
projection = [normal(1), normal(2), 0];
quiver3(0, 0, 0, projection(1), projection(2), projection(3));
% Add dashed line
plot3([normal(1), projection(1)], [normal(2), projection(2)], [normal(3), projection(3)], ‘–k’);
view(45,30);
axis equal
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’);Hi I have the following code to plot a 2D plane in 3D space.
the plane is describe by their dip angle and azimuth and the center point is at [x,y] = [0,0]
I intend to modify this code so that it can plot 3 planes in the same axis. However, the location for each plane will be varies depending on the x and y location.
planedip = 30;
planeazim = 120;
% Convert angles to radians
dip_angle_rad = deg2rad(planedip);
dip_azimuth_rad = deg2rad(360 – planeazim); % rotate from CCW to CW
% Define normal vector of plane
normal = [sin(dip_angle_rad)*cos(dip_azimuth_rad), sin(dip_angle_rad)*sin(dip_azimuth_rad), cos(dip_angle_rad)];
% Define two vectors in plane
v1 = [1, 0, (-normal(1)/normal(3))];
v2 = cross(normal, v1);
% Plot plane
x = linspace(-1,1,10);
y = linspace(-1,1,10);
[X,Y] = meshgrid(x,y);
Z = (-normal(1)*X – normal(2)*Y)/normal(3);
surf(X,Y,Z,’FaceColor’,[0.5,0.5,0.5],’FaceAlpha’,0.5,’EdgeColor’,’none’);
% Add annotations
hold on
quiver3(0, 0, 0, normal(1), normal(2), normal(3));
projection = [normal(1), normal(2), 0];
quiver3(0, 0, 0, projection(1), projection(2), projection(3));
% Add dashed line
plot3([normal(1), projection(1)], [normal(2), projection(2)], [normal(3), projection(3)], ‘–k’);
view(45,30);
axis equal
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’); Hi I have the following code to plot a 2D plane in 3D space.
the plane is describe by their dip angle and azimuth and the center point is at [x,y] = [0,0]
I intend to modify this code so that it can plot 3 planes in the same axis. However, the location for each plane will be varies depending on the x and y location.
planedip = 30;
planeazim = 120;
% Convert angles to radians
dip_angle_rad = deg2rad(planedip);
dip_azimuth_rad = deg2rad(360 – planeazim); % rotate from CCW to CW
% Define normal vector of plane
normal = [sin(dip_angle_rad)*cos(dip_azimuth_rad), sin(dip_angle_rad)*sin(dip_azimuth_rad), cos(dip_angle_rad)];
% Define two vectors in plane
v1 = [1, 0, (-normal(1)/normal(3))];
v2 = cross(normal, v1);
% Plot plane
x = linspace(-1,1,10);
y = linspace(-1,1,10);
[X,Y] = meshgrid(x,y);
Z = (-normal(1)*X – normal(2)*Y)/normal(3);
surf(X,Y,Z,’FaceColor’,[0.5,0.5,0.5],’FaceAlpha’,0.5,’EdgeColor’,’none’);
% Add annotations
hold on
quiver3(0, 0, 0, normal(1), normal(2), normal(3));
projection = [normal(1), normal(2), 0];
quiver3(0, 0, 0, projection(1), projection(2), projection(3));
% Add dashed line
plot3([normal(1), projection(1)], [normal(2), projection(2)], [normal(3), projection(3)], ‘–k’);
view(45,30);
axis equal
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’); 2d plane MATLAB Answers — New Questions