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

6 views (last 30 days)
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'

Answers (1)

Matt J
Matt J on 17 Jan 2022
You can rotate and replicate the single dome using hgtransform, similar to this example,
  1 Comment
Johnny Dessoulavy
Johnny Dessoulavy on 17 Jan 2022
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

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!