extrude a 2d patch/surface to 3d volume

11 views (last 30 days)
saad sulaiman
saad sulaiman on 18 Oct 2022
Answered: Ayush on 30 Aug 2023
from a set of data points, I have already plotted a 2d surface and now I would like to extrude it as a volume, just like in any CAD software. for simplicity, I have attached a picture of a simple patch with the coordinates and so, I would like to add thickness to it in z-direction.

Answers (1)

Ayush
Ayush on 30 Aug 2023
Hi Saad,
I understand that you want to extrude your 2D patch into a 3D volume by adding some thickness in the Z-direction.
It can be done in the following manner:
1. Add the z-coordinates in your vertex matrix (in your case variable “x”). Here is a sample code for your reference:
% Create the vertex matrix with added z-coordinate for extrusion
vertices = [
x, zeros(size(x, 1), 1); % Original vertices with z-coordinate = 0
x, ones(size(x, 1), 1); % Vertices extruded in the z-direction with z-coordinate = 1
];
2. Add the corresponding faces to the face matrix (in your case variable “y”). Here is a sample code for your reference:
faces = [
1, 2, 4, 3; % Face 1 (vertices 1, 2, 4, 3)
1, 2, 6, 5; % Face 2 (vertices 1, 2, 6, 5)
1, 3, 7, 5; % Face 3 (vertices 1, 3, 7, 5)
.
.
.
];
3. Use the “patch” function to make the respective polygon. You can refer to the below documentation to know more about the “patch” function:
4. Add the line of code “view(3)” to visualise the 3D volume. You can refer to the below documentation to know more about the “view” function:
Hope this helps,
Regards,
Ayush Misra

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!