How to create surface plot from vertical lines?
4 ビュー (過去 30 日間)
古いコメントを表示
Hello, I'd like to ask few questions related to creating 3D surfaces.
I have created wireframe figure(red) of propeller blade as below, but I don't know how to create surface.
I created (z-direction) wireframes by connecting points at same index("lv" in first for-loop) in all sections. For example, let's say there are 3 sections A, B and C, and each section carries same number of points. Those points are (x, y, z) coordinates, and each section is 2D matrix with same size.
Then, I connect 1st point of A with 1st point of B, and 1st point of C, using plot3, and so on.
I believe, I can create single surface by using 2-vertical(Z-direction) lines, and the very bottom section and top section. I tried to implement it by myself, but the result shown in blue wasn't satisfying.
Below is the code I used to create the figure above.
% ----------------- creates wireframe here --------------------
lv_dim = [size(coordinates_list)];
rows = lv_dim(1); % number of points in each section
depth = lv_dim(3); % number of all sections
% coordinates_list: 3D matrix that contains x-y-z coordinates of each
% section
for lv = 1:rows
x_line = reshape([coordinates_list(lv, 1, :)], [1, depth]); % X coordinate of lv-th point, from all sections in coordinates_list
y_line = reshape([coordinates_list(lv, 2, :)], [1, depth]); % Y coordinate of lv-th point, from all sections in coordinates_list
z_line = reshape([coordinates_list(lv, 3, :)], [1, depth]); % Z coordinate of lv-th point, from all sections in coordinates_list
wire_line(lv) = plot3(app.UIAxes, x_line, y_line, z_line, 'r-'); % Create lv-th wire frame at app.UIAxes,(shown above).
axis(app.UIAxes,'equal');
hold(app.UIAxes,'on');
end
% ------------------ creates surface here ------------------------
for lv = 2:rows
% left vertical(Z-direction) boundary
x_line_l = reshape([coordinates_list(lv-1, 1, :)], [1, depth]); % reshape matrix of X-coordinates from left boundary into colum vector
y_line_l = reshape([coordinates_list(lv-1, 2, :)], [1, depth]); % reshape matrix of Y-coordinates from left boundary into colum vector
z_line_l = reshape([coordinates_list(lv-1, 3, :)], [1, depth]); % reshape matrix of Z-coordinates from left boundary into colum vector
% right vertical(Z-direction) boundary
x_line_r = reshape([coordinates_list(lv, 1, :)], [1, depth]); % reshape matrix of X-coordinates from right boundary into colum vector
y_line_r = reshape([coordinates_list(lv, 2, :)], [1, depth]); % reshape matrix of Y-coordinates from right boundary into colum vector
z_line_r = reshape([coordinates_list(lv, 3, :)], [1, depth]); % reshape matrix of Z-coordinates from right boundary into colum vector
% concatenate colum vectors per each axis(x, y, z) and-
% -transpose.
surf_line(lv) = surf(app.UIAxes,[[x_line_l x_line_r]', [y_line_l y_line_r]', [z_line_l z_line_r]']);
axis(app.UIAxes,'equal');
hold(app.UIAxes,'on');
end
I sincerely appreciate you for your attention, and I'd be happy to hear and implement your suggestions.
0 件のコメント
回答 (1 件)
Star Strider
2023 年 3 月 15 日
If you can change that to a series of cross-sections of the propeller blade at various points along its length, the approach in how to convert 2D graph to 3D? could work.
4 件のコメント
Star Strider
2023 年 3 月 29 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
参考
カテゴリ
Help Center および File Exchange で Formatting and Annotation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!