<p>You can't create a solid by extruding a single curve or set of curves. Even if they are closed. Think about a circle on on the XY plane. If you extrude the circle along the Z axis you have an uncapped cylinder.</p>
<p>Let's walk it back a bit though. If you have a single Bezier curve and extrude it you create a Bezier surface. You can quickly get your head around a Bezier surface if you understand a Bezier curve.</p>
<p><a href="https://en.wikipedia.org/wiki/B%C3%A9zier_surface" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/B%C3%A9zier_surface</a></p>
<p>You can think of the Bezier surface as a blend through a set of curves. To extrude the curve you simply duplicate your original curve, and set the control points Z value to your extrusion distance. The original curve and new extruded curve create the control points for your surface.</p>
<p>I actually have a Bezier surface example I wrote in Python. The only dependencies are Numpy and Matplotlib. It also uses the Bernstein Basis function imported from another file in the repository. You can play with the control points to see how modifying them effects the resulting surface. There's no error checking so you'll have to know what you're doing.</p>
<p><a href="https://github.com/jrz371/IntroToNurbsPython/blob/master/BezierSurface.py" rel="nofollow noreferrer">https://github.com/jrz371/IntroToNurbsPython/blob/master/BezierSurface.py</a></p>
<p>As for parameterizing the span and chord length you'll have to derive those yourself. I'm unfamiliar with your requirements. Understanding the Bezier curves and surfaces thoroughly should help you resolve that.</p>
<p>Some of the comment suggest evaluating the curve and creating triangles. This is a bad approach. Tessellating a Bezier surface causes you to lose a lot of information. The Bezier surface is smooth whereas a set of triangles is not. For drawing a Bezier surface they are ultimately tessellated for the display, but they are kept in the original Bezier representation for modification.</p>
<p>Bezier curves are also not the best representation for curves and surfaces. BSplines and NURBS are able to represent more complex surfaces and curves. Understanding Beziers is fundamental prerequisite before tackling those.</p>
<p>Good luck!</p>

CC BY-SA 4.0
2021-05-12T07:36:11.637Z
2021-05-12T07:36:11.637Z
Joshua Kennedy
<p><a href="https://i.sstatic.net/rOJfe.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/rOJfe.png" alt="The parameters of the rational Bezier curve have been converted into a discrete representation of points using this formula." /></a></p>
<p>Where P is the control point, w is weight.</p>
<p>I plan to extrude this 2d representation into 3d. I have a discrete 2D representation (array which has [n_points, 2, 1] for each sample) of an airfoil that has to be extruded to form a wing along the z axis which has parameters like Span and variation on chord length. In theory, this seems easy, however, in code, I can't find any basis on how to implement it.</p>
<p>I have not found anything regarding this which doesn't use high utility libraries. Any leads or explanations will be highly appreciated.</p>

CC BY-SA 4.0
2021-04-26T15:36:22.597Z
What exactly is it that you are struggling with? Seems quite straightforward to me: Evaluate the curve at certain coordinates and connect the data points with triangles. Since I guess this is a homework question, I suggest studying the material from the course first. Telling us a bit more about what particular problems you are facing with this task will help us to guide you in the right direction.
wychmaster
CC BY-SA 4.0
2021-04-27T17:06:25.470Z
@wychmaster I have updated the question. This is for my undergrad project. I am making a Generative Neural network architecture that outputs an extruded form of the 2d discrete representation ie a 3d model representation of the same. This is why I can't use a high utility library like blender or pygimli since they cant be part of model architecture.
sarva
CC BY-SA 4.0
2021-04-30T09:15:51.030Z
Sorry, for returning so late, but I am currently very busy. If you have discrete points in 2d I am still not seeing what your exact problem is. To keep it simple, let's assume you have a rectangular wing. Your 2d coordinates are x and y. Now create two copies of those coordinates and add a z coordinate. The first profile gets z=0 and the second z=l, where l is the wingspan. Now connect the points with triangles to get a surface. I might be able to give you a full answer if this isn't enough, but it might take a while.
wychmaster
CC BY-SA 4.0
2021-05-01T19:42:10.523Z
@wychmaster What exactly do you mean by triangles? As in triangular tesselation? Because I am trying to make a perfect boundary representation one.
sarva
CC BY-SA 4.0
2021-05-06T07:40:03.753Z
Let's say you have two times the same airfoil with just different z coordinates. We name the first one A and the second one B. Then you can create 2*N triangles from it, where N is the number of airfoil raster points, the first two triangles would be `(A[1], A[2], B[1])` and `(B[1], B[2], A[2])`. Then just add just 1 to all indices for the next ones. The last triangles would be `(A[N], A[1], B[N])` and `(B[N], B[1], A[1])`. (Note that I started indexing with 1 and not with 0)
wychmaster
CC BY-SA 4.0
2021-05-09T19:28:40.190Z
@wychmaster thanks for your explanation. I think I understood.
sarva
<3d><2d><bezier-curve><parametrization>
How do I extrude a 2D Bezier curve representation into a 3D solid using Python?
sarva
# How do I extrude a 2D Bezier curve representation into a 3D solid using Python?

(Asked by: username_0 on 2021-04-26)

[![The parameters of the rational Bezier curve have been converted into a discrete representation of points using this formula.](https://i.sstatic.net/rOJfe.png)](https://i.sstatic.net/rOJfe.png)

Where P is the control point, w is weight.

I plan to extrude this 2d representation into 3d. I have a discrete 2D representation (array which has [n\_points, 2, 1] for each sample) of an airfoil that has to be extruded to form a wing along the z axis which has parameters like Span and variation on chord length. In theory, this seems easy, however, in code, I can't find any basis on how to implement it.

I have not found anything regarding this which doesn't use high utility libraries. Any leads or explanations will be highly appreciated.

**Tags:** 3d, 2d, bezier-curve, parametrization

> **Comments:**
> **username_1**: What exactly is it that you are struggling with? Seems quite straightforward to me: Evaluate the curve at certain coordinates and connect the data points with triangles. Since I guess this is a homework question, I suggest studying the material from the course first. Telling us a bit more about what particular problems you are facing with this task will help us to guide you in the right direction.  
> **username_0**: @username_1 I have updated the question. This is for my undergrad project. I am making a Generative Neural network architecture that outputs an extruded form of the 2d discrete representation ie a 3d model representation of the same. This is why I can't use a high utility library like blender or pygimli since they cant be part of model architecture.  
> **username_1**: Sorry, for returning so late, but I am currently very busy. If you have discrete points in 2d I am still not seeing what your exact problem is. To keep it simple, let's assume you have a rectangular wing. Your 2d coordinates are x and y. Now create two copies of those coordinates and add a z coordinate. The first profile gets z=0 and the second z=l, where l is the wingspan. Now connect the points with triangles to get a surface. I might be able to give you a full answer if this isn't enough, but it might take a while.  
> **username_0**: @username_1 What exactly do you mean by triangles? As in triangular tesselation? Because I am trying to make a perfect boundary representation one.  
> **username_1**: Let's say you have two times the same airfoil with just different z coordinates. We name the first one A and the second one B. Then you can create 2*N triangles from it, where N is the number of airfoil raster points, the first two triangles would be `(A[1], A[2], B[1])` and `(B[1], B[2], A[2])`. Then just add just 1 to all indices for the next ones. The last triangles would be `(A[N], A[1], B[N])` and `(B[N], B[1], A[1])`. (Note that I started indexing with 1 and not with 0)  
> **username_0**: @username_1 thanks for your explanation. I think I understood.  

---

## 1 answers

### Answer by username_2 on 2021-05-12. Score: 2 | Accepted answer

You can't create a solid by extruding a single curve or set of curves. Even if they are closed. Think about a circle on on the XY plane. If you extrude the circle along the Z axis you have an uncapped cylinder.

Let's walk it back a bit though. If you have a single Bezier curve and extrude it you create a Bezier surface. You can quickly get your head around a Bezier surface if you understand a Bezier curve.

<https://en.wikipedia.org/wiki/B%C3%A9zier_surface>

You can think of the Bezier surface as a blend through a set of curves. To extrude the curve you simply duplicate your original curve, and set the control points Z value to your extrusion distance. The original curve and new extruded curve create the control points for your surface.

I actually have a Bezier surface example I wrote in Python. The only dependencies are Numpy and Matplotlib. It also uses the Bernstein Basis function imported from another file in the repository. You can play with the control points to see how modifying them effects the resulting surface. There's no error checking so you'll have to know what you're doing.

<https://github.com/jrz371/IntroToNurbsPython/blob/master/BezierSurface.py>

As for parameterizing the span and chord length you'll have to derive those yourself. I'm unfamiliar with your requirements. Understanding the Bezier curves and surfaces thoroughly should help you resolve that.

Some of the comment suggest evaluating the curve and creating triangles. This is a bad approach. Tessellating a Bezier surface causes you to lose a lot of information. The Bezier surface is smooth whereas a set of triangles is not. For drawing a Bezier surface they are ultimately tessellated for the display, but they are kept in the original Bezier representation for modification.

Bezier curves are also not the best representation for curves and surfaces. BSplines and NURBS are able to represent more complex surfaces and curves. Understanding Beziers is fundamental prerequisite before tackling those.

Good luck!


---

