Pipe elbow creation using MATLAB code
10 views (last 30 days)
Show older comments
Hi
I am done with my MATLAB code which creates as many straight pipes I want. However, I want to connect them using pipe elbow looks like below. Any idea how to create this elbow in MATLAB?
2 Comments
John D'Errico
on 5 Jan 2023
What does CREATING it mean? As after all, you already have a picture of what you want, and MATLAB is not a tool I would probably use to drive a CNC mill. A 90 degree elbow like that might be a difficult project to make anyway, even if I did have a million dollars of tooling on hand. Anyway, a pipe elbow like that would probably be formed using a hot extrusion process, and then bent into shape. And that means if I did want to create that object, a pipe bender would be the tool of choice. Just throw some heavy duty hydraulics at the problem.
Ok, that is all irrelevant, since I assume you want to make something in MATLAB, purely for graphics purposes. And for that, you already have all the curve radii, so all you needs are some circle segments, unless you also want pretty shading and lighting.
So what are you looking for here?
Answers (1)
John D'Errico
on 25 Jan 2023
Edited: John D'Errico
on 25 Jan 2023
What is not working? Why do you think it is not working?
I would conjecture that one problem you have is you cannot model a 90 degree elbow as you tried to do. Your circles are drawn always parallel to each other. And that MUST be incorrect.
A second problem is you are drawing only circles. They will have no connection to each other along the length of the elbow. And that two will be a problem. So do this better by drawing a true surface, as what I would call a 2-manifold. Setting it up to follow a curve in space is a good idea.
The nice thing is, this makes it also trivial to generate a series of pipes, because the cylinder code I wrote does not care if the centerline path is a linear segment or a circular arc. For example
[pipe1x,pipe1y,pipe1z] = generalCylinder([-1 1 0;0 1 0],0.25,50);
[pipe2x,pipe2y,pipe2z] = generalCylinder([1 0 0;1 -1 0],0.25,50);
phi = linspace(0,pi/2)';
elbowarcxyz = 1*[cos(phi),sin(phi),zeros(numel(phi),1)];
[elbowx,elbowy,elbowz] = generalCylinder(elbowarcxyz,0.25,50);
H1 = surf(pipe1x,pipe1y,pipe1z);
hold on
H2 = surf(pipe2x,pipe2y,pipe2z);
H3 = surf(elbowx,elbowy,elbowz);
H1.FaceColor = 'b';
H2.FaceColor = 'g';
H3.FaceColor = 'r';
box on
hold off
axis equal
I attached generalCylinder to this answer.
Now all you need do is create a centerline path through space, and then use the cylinder code to build the cylinder as a surface that follows that path.
7 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!