Creating a inclined plane with an adjustable dome pattern cutout of it.

10 次查看(过去 30 天)
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'

回答(1 个)

Matt J
Matt J 2022-1-17
You can rotate and replicate the single dome using hgtransform, similar to this example,
  1 个评论
Johnny Dessoulavy
Johnny Dessoulavy 2022-1-17
I just tried doing that, but when i attmepted to make Z (the dome matrix) a set it told me that it was unable to and didnt give me an further error message as to try and fix that problem

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by