I need to connect two polygons of different dimensions into one section. These polygons can be in different planes relative to each other. Polygons can also be convex or non convex. I need an algorithm like Blender - Bridge edge loops.
My current idea is to add the missing number of vertices to a smaller polygon (but how do I position them best?). Then choose a point of relative center of the polygon, and sort the vertices clockwise relative to it. And pair each of the vertices from the two polygons to get a connected section.
If there is a ready algorithm that solves my problem I would like you to show it to me.
If each of the two end profiles is contained entirely within one of the half-spaces defined by the plane of the other end profile, and the profiles are convex, a simple approach would be to form the side faces based on angle around the profiles.
Start by defining a reference normal to coordinate the vertex matching. An easy choice is the average of the two end profiles' plane normals, oriented in the same direction.
Now, for each edge in the first profile, find its outward normal perpendicular to the reference normal. Find the vertex in the other profile which is extremal in that direction. Create a triangular face containing that edge in the first profile and that vertex in the second profile. Once all those are created, do the same thing with the edges in the second profile, connecting them to vertices in the first profile.
This can be efficiently implemented with a rotating-calipers algorithm, iterating around the two profiles' perimeters in angle order and outputting a face whenever the angle hits the tangent of one of the profiles' edges.
For profiles which are not convex you can use a similar algorithm. Find the convex hull of each profile, then run the above algorithm on the hulls. When you hit an edge which is in the convex hull but not in the profile that generated it, you instead output a triangle face for each profile edge replaced by the hull edge (that is, each edge in the run of profile edges between the two endpoints of the hull edge).