Creating a inclined plane with an adjustable dome pattern cutout of it.
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to create a plane which is inclined at X angle. on this plane i want to be able to create multiple dome cutouts that have an adjustable radius and depth. The dome placements are not important as long as there is a pattern of them whihc can extend over a plane of MxN.
I have been able to create a the inlcined plane and the dome but havent been able to merge the two together. My code below just has a singular dome, but in reality I want multiple to go up and down the plane. I tried to get at least one dome on the plane (unsuccessful as of yet) before attempting to replicate it with rep element or something similar.
Effectively, I am trying to create a surface of a golf ball on this inclined plane.
clc; clear all; close all
nrow = 94; ncol = 200; angle = 20; xsize = 2000; ysize = 2000;
%% Setting the flat plane
angle = angle; % angle in degrees
dx = xsize/ncol; dy = ysize/nrow;
angle = angle*pi/180;
r = 10;
z_flat=zeros(nrow,ncol);
for j=1:nrow
for i=1:ncol
z_flat(j,i) = (i-1)*dx*sin(angle);
end
end
%% Setting the rows and columns into a meshed matrix to generate x and y coordinates
dx_mat = linspace(0,xsize,length(z_flat));
dy_mat = linspace(0,ysize,height(z_flat));
[x y] = meshgrid(dx_mat, dy_mat);
%% Creating the Dome
R = 10;
[X,Y] = meshgrid(-R:.1:R);
Z = (-sqrt(R.^2 - X.^2 - Y.^2))/(ceil(0.9*R));
Z(imag(Z) ~= 0) = 0;
mesh(X,Y,Z);
Z = imresize(Z,[nrow,ncol]);
%%
%% combining the flat and domed matrices
z_matrix = (z_flat + Z);
surf(x,y,z_matrix);
axis tight
xlabel 'Planar Depth (m)', ylabel 'Planar Width (m)',zlabel 'Planar Height'
0 comentarios
Respuestas (1)
Matt J
el 17 de En. de 2022
You can rotate and replicate the single dome using hgtransform, similar to this example,
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!