How do I extrude a 2D Bezier curve representation into a 3D solid using Python? 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.
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!