Polygon Offset/ Minkowski sum with a sphere algorithm - c++

I am looking for a accurate polygon offset algorithm for 3D polygons, convex and non convex. This can also be achieved with Minkowski sum with a sphere. I know CGAL provide a minkowski package.
However, is there an easy algorithm that I can implement to achieve this task of polygon offse in 3D.
Thanks.
Cheers,
CB

There are easy-ish approaches for offsetting convex polyhedra -- you just move each polygon along its normal, convert edges into cylindrical arcs, and vertices into spherical sectors. For concave geometry, though, this will produce intersecting and degenerate faces. If all you want to do is render then that's okay... but if you intend to do anything interesting with the offset geometry, you really need the big guns provided by things like CGAL.

Related

Triangulation 3D algorithm

I have thousands of polygon on 3D space which contains more than 3 vertex. I want partition each polygon into a set of triangles. I have been looking all over the internet and I can not find any algorithm on 3D that does that. I have found many algorithms working on 2D like ear clipping and Delaunay triangulation. But I can not find any algorithm for 3D.
I saw many same questions on this site which answered with "use the Delaunay triangulation algorithm". But I have seen that this algorithm is for 2D:
http://www.geom.uiuc.edu/~samuelp/del_project.html
Implement an algorithm for finding the constrained Delaunay triangulation of a given point set in two dimensions.
What 3D Triangulation algorithm can I use?
I am using OpenGL with C++.
You can use the GLUTesselator:
http://www.glprogramming.com/red/chapter11.html
Also note that a 3D polygon will have many faces which can be translated onto an axis aligned 2D plane, triangulated, and then the results translated back into the plane defined by the face.
You can use a delaunay triangulation but with tetrahedons. Basically use Bowyer Watson with circumspheres:http://blog.mmacklin.com/tag/meshing/.

Math Behind Flash Vector Graphics?

I've been searching for vector graphics and flash for quite some time but I haven't really found what I was looking for. Can anyone tell me exactly what area of mathematics is required for building vector images in 3D space? Is this just vector math? I saw some C++ libraries for it but I wasn't sure if it was the sort of vectors meant to for smaller file size like flash images are. Thanks in advance.
If you're wanting to do something from scratch (there are plenty of open-source libraries out there if you don't), keep in mind that "vector graphics" (this is different than the idea of a 3D space vector) themselves are typically based on parametric curves like Bezier curves, which are essentially 3rd degree polynomials for each x, y, and/or z point parameterized from a value t that goes from 0 to 1. Now projecting the texture-map image you create with those curves (i.e., the so-called "vector graphics" image) onto triangle polygon via uv coordinates would involve some interpolation, which is fairly straight forward linear algebra, as you would utilize the barycentric coordinate of the 3D point on the surface of the triangle polygon in order to calculate the uv point you want to look-up from the texture.
So essentially the steps are:
Create the parametric-curve based image (i.e, the "vector graphic") and make a texture map out of it
That texture map will have uv coordinates
When you rasterize the 3D triangle polygon, you will get a barycentric coordinate on the surface of the triangle from the actual 3D points of the triangle polygon. Those points of the polygon should also have UV coordinates assigned to them.
Use the barycentric coordinates to calculate the uv coordinate on the texture map.
When you get that color from the texture map, then shade the triangle (i.e, calculate lighting, etc. if that's what you're doing, or just save that color of the pixel if there is no lighting).
Please note I haven't gotten into antialiasing, that's a completely different beast. Best thing if you don't know what you're doing there is to simply brute-force antialias through super-sampling (i.e., render a really big image and then average pixels to shrink it back to the desired size).
If you've taken multivariable calculus, the concepts behind parametric curves and surfaces should be familiar, and a basic understanding of linear algebra would be necessary in order to work with barycentric coordinates and linear interpolation from 3D vectors.

Alpha shapes from weighted Delaunay Triangulation

I am looking for an algorithm to solve alpha shapes from weighted delaunay triangulation (assuming we have weighted DT) in 2D and 3D. I've looked at a few online links that provide complicated explanations. It'll be great if i can get pseudo code of the algorithm with good explanation.
You can try to use CGAL that provides both 3D and 2D weighted alpha-shapes.
Examples in 3D are available here and here.
The 2D case is similar.
Alpha shapes is alpha value and every edges exceeding alpha. Hence you can remove those edges. I don't think it needs dt. a weighted dt.

Polygon Partitioning vs Triangulation

I recently asked this question about how to cut down a concave polygon to convex ones, and I was suggested to do Triangulation or Polygon Partitioning.
The library I'm using (SFML\Box2D) only takes convex shapes.
This is what I want to know:
Is Polygon Partitioning, or Triangulation of Polygons faster?
How does Polygon Partitioning work/ How do you do it?
Don't forget Triangulation doesn't require convex shapes to be made either...
Not a full answer to your question, but if you have a general polygon (concave, convex, whatever) and you are looking to triangulate it (for subsequent openGL style rendering perhaps) you could look into "constrained Delaunay triangulation" packages. One such example is the Triangle package, which is reputed to be fast and robust.
As I understand it, the algorithms used in Triangle exhibit O(nlogn) runtime complexity.
Polygon partitioning splits your polygon into convex polygons.
Triangulation splits it into triangles.
As far as I understand, partitioning into triangles requires that you first perform polygon partitioning, since partitioning convex polygon into triangles is relatively trivial.
Splitting polyon into convex polygons is the hard part.
I have written a program that does both for a class and if you want I can dig it up.
Here's my code:
https://github.com/meshko/triangulator/tree/master/som
I haven't touched in 10 years so beware of.

Polyhedron from the plane equations

I have a few planes (3-10 of them) in 3d defined by their equations (three coefficients and the offset). These planes are the edges of a convex polyhedron. I need to draw that polyhedron. How can I do that? What software/libraries/algorithms can I use? I work in Linux and I'm usually using C or C++.
Every plane pair intersects in a line on both planes. Each plane then contains a set of lines that intersect in points, all of those are the edge points of your polyhedron you'll have to connect in a convex way.
With some math/geometry skills, you should be able to solve this, but using a library (f.e. CGAL) of course simplifies it and prevent you from reinventing the wheel.