Create a 3D polyhedron from 2D convex polygon in bullet physics - computational-geometry

I have a convex polygon in Oxy plane (defined by some vertices and edges). I would like to create a 3D polyhedron from extruding this polygon in z axis for some distance h. How can I do this in bullet physics?
Thank you for your time.

The extrusion is simple to do by hand. For each vertex in the polygon you duplicate it, and set the Z value to the distance h. Then you can create a btConvexHullShape from the points in the set. Since it's a convex hull and not a triangle mesh you don't need to worry about the face information. If you look at the btConvexHullShape constructor you'll notice it only takes a list of points as the parameter.

Related

Project 3D polygon into a 2D plane such that the vertices are in counter clockwise order

Some fast algorithms for working with polygons require the vertices of the polygon to have a specific order (clockwise or counter clockwise with respect to the polygon's plane normal).
To use those algorithms in 3D planar polygons (where all the points lie in a particular plane) one can perform a change of basis to a basis spanned by two orthogonal vectors that lie in the plane and a plane normal vector.
Is there a way to always find a basis in which the polygon vertices are always in counter clockwise (or clockwise) order?
Perhaps the best method is to compute the signed area of the polygon, and if it is negative, you know your vertices are clockwise; so reverse. If it is positive, your vertices are counterclockwise.
Search for "signed area of polygon." Here is one Mathematica link:

What algorithm's can be used to fill an irregular 3D object?

I have an irregular polygon in 3D, and have coordinates of points present on the boundary of the polygon. Assume that I have placed cubes of some size on all such points present on the boundary. With the help of these cubes I can search for all 3D objects which intersect with my polygon. Now in order search for all objects which are either inside or outside my polygon I need to populate the 3D polygon with such cubes.
Can anyone help on how can I fill in my 3D polygon with all such cubes.
You dont need to fill the polyhedron (this is the name of a 3d polygon), instead you could calculate its hull, which might be a Convex Hull or concave hull depending on your intent.

Intersection of a line and a concave polygon 3D

My problem is to find if a generic (convex or concave) polygon and a rectangular polygon in 3D space has a not-null intersection. Each polygon is defined by the set of the ordinated contour points (if point p1 is after/before point p2 the edge p1-p2 exists).
It is easy to find the intersection line of the two plane of the polygons so the problem is finding the intersections of a line and the finite polygons and if the resulting intersections have a portion in common. I found algorithms for the intersection of a line and a convex polygon but I can't find anything for the general case of concave polygon.
Any suggestion?
Thank you
find the intersection point of the plane-intersection line with every edge of both figures. From there its s straightforward problem of looking at the ordering of the points on the line to check for any overlap.
Of course the special case where they are coplanar is a whole other problem..
There are usually no fast solutions for concave polygon intersection / containment/ etc queries.
The general solution is always to triangulate the polygon into a series of convex triangles, then run your intersection test with those triangles.
If you can rely on the polygon to be planar, you can first intersect the line with the plane and then transform the intersection point into the coordinate system of the plane.
Assuming you have also transformed all the vertices of the polygon, the problem is now to decide whether the 2D intersection point is within a 2D polygon.

A plane subdivision into non-overlapping regions by a set of polygons

Please see the example image:
There are a set of polygons (convex, non-convex, but not self-intersecting) in a plane. Polygon is defined by vertices – points (x and y coordinates, cartesian coordinate system).
Example set of polygons:
The first polygon is A, B, C.
The second polygon is D, E, F, G, H, I, J.
The third polygon is K, L, M, N.
The fourth polygon is O, P, Q.
Polygons divide a plane into regions. Some parts of polygons may be overlapping (like the first and the second polygon, the second polygon and the third polygon). This overlapping parts is seperate regions too. Some polygons may be inside others (like the fourth polygon inside the second polygon).
Example regions after subdivision: blue, pink, green, orange, brown and purple.
I imagine for simplicity that the plane is a rectangle with constant x, y coordinates.
The Goal
Detect the region (blue, pink, green, etc.) by the query point.
I am looking for algorithm and data structure for a plane subdivision with these assumptions.
First transform your set of polygons into a set of non-overlapping polygons by iteratively looking for pairwise intersections and replacing the pair of intersecting polygons with their intersection and the original polygons minus the intersection. This might be easier and faster if you first split each polygon into a set of convex polygons (the convex polygons can simply "inherit" the "color" of the original concave polygon).
You can then put the polygons into a quad-tree or a similar data structure which allows you to quickly select candidate polygons for membership tests for a given query point.
You will need to define what is happening on edges shared between multiple polygons.
I can recommend a trapezoidal decomposition http://en.wikipedia.org/wiki/Point_location#Trapezoidal_decomposition for efficient point queries in a planar subdivision.
In your case, the subdivision is defined indirectly so there is an extra step. You can try three approaches:
1) use a general polygon intersection algorithm that you will call incrementally,
2) form the trapezoidal decompositions of the polygons and perform fusions of these trapezoidal maps,
3) modify an existing trapezoidal decomposition algorithm so that it accepts as input a subdivision formed of overlapping polygons.
You will need to use some 2D Computational Geometry library... and courage.
ALTERNATIVE:
If your precision requirements are not too high, use a bitmap and fill every polygon, changing the color when pixels already painted are met.

Triangulate set of 3D points

I have a set of Points [X, Y, Z]
as an interest points of a 3D Object
and I'm searching for an algorithm that used to convert this points into 3D-Model "Triangulation Algorithm"
I just tried "Delaunay Triangulations" algorithm, but its result is the convex hull of my set of points
and this will not work for me as all inner points will be neglected
Any Suggestions?
The Delaunay triangulation in 3D produces a partition of the convex hull into tetrahedra, with all your points becoming vertices of the tetrahedra. Inner points will not be "neglected."
Here is an image from the CGAL manual:

Resources