CGAL-implementation of the intersection of two cubic (planar) Bezier/Splines offsets - cgal

CGAL's manual suggests that there is no such implementation, if you know anything more let me know
N

This sounds like two questions, rather than one:
(1) How to intersect two planar cubic Bezier curves
(2) How to offset a planar cubic Bezier curve
I don't understand the statement that "there is no implementation". Maybe they just mean that there is no implementation in CGAL.
Both problems require numerical methods or approximation -- neither one has a closed-form solution.
But they are both well-known problems with many workable (approximate) solutions available. Searching for "intersect Bezier curves" or "offset Bezier curve" will return dozens of useful references and code samples.
If you want to solve these problems using CGAL ...
(1) Intersection. This is basically a root-finding problem, and CGAL has a bivariate root finder called AlgebraicKernel_d_2::Solve_2.
(2) Offsetting. Could perhaps be done using the Minkowski sum functions. Look at approximated_offset_2, for example. The result will be polygonal, but that might be good enough for your purposes. This is really a curve approximation problem, for which CGAL has no tools, as far as I can see.

For anyone interested:
"There is a CGAL implementation of an exact arrangement of Bezier curves ( http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Arrangement_on_surface_2/Chapter_main.html#Subsection_32.6.7 )" cheers Iddo Hanniel

Related

CGAL: Simplify convex polyhedra in 3D

I have been using the cgal library to generate convex hulls which are further used for discrete element simulations. Currently, I am trying to make the polyhedral particles break, which is right now implemented as plane clipping of the polyhedron. The problem is that after several (sometimes even one) clipping, the polyhedrons start having "bad" attributes, such as nearly degenerate faces, nearly coplanar edges or nearly degenerate edges, which cause problems in the contact calculation. I have been looking at CGAL/Surface_mesh_simplification routines and used the edge_collapse function, but it does not preserve convexity of the particles. Is there any way to use routines from cgal for convex polyhedra simplifications while preserving convexity?
You can try using the function isotropic_remeshing(). While there is no guarantee that the output will stay convex, the points are guaranteed to be on the input mesh. If you have some sharp edges you want to preserve, you can specify it to the function and it will take them into account.

CGAL 3D surface mesh generation for unbounded implicit surfaces

This is again a question about the CGAL 3D surface mesher.
http://doc.cgal.org/latest/Surface_mesher/index.html#Chapter_3D_Surface_Mesh_Generation
With the definition
Surface_3 surface(sphere_function, // pointer to function
Sphere_3(CGAL::ORIGIN, 64.0)); // bounding sphere
(as given too in the example code) I define an implicit surface given by 'sphere function' and a Sphere_3 of radius 8.
The difference is now, that the zeros of 'sphere function' are (contrary to its now misleading name) no longer bounded and inside Sphere_3. Instead 'sphere_function' represents an unbounded surface (think of x^2 + y^2 - z^2 - 1 = 0) and my intention is to triangularize its part that is in the Sphere_3.
In my examples up to now this worked quite well, if only for some annoying problem, I do not know how to overcome: The boundaries, where the implicit surface meets the Sphere, are very "rough" or "jagged" in a more than acceptable amount.
I already tried the 'Manifold_with_boundary_tag()', but it gave no improvements.
One road to improve the output that I am contemplating, is converting the triangulated mesh (a C2t3) into a Polyhedron_3 and this in a Nef_polyhedron and intersect that with a Nef_polyhedron well approximating a slightly smaller Sphere. But this seems a bit like shooting with cannons for sparrows, nevertheless I have currently no better idea and googling gave me also no hint. So my question: What to do about this problem? Can it be done with CGAL (and moderate programming effort) or is it necessary or better to use another system?
(Just for explanation for what I need this: I try to develop a program that constructs 3D-printable models of algebraic surfaces and having a smooth and also in the boundaries smooth triangulation is my last step that is missing before I can hand the surface over to OpenSCAD to generate a solid body of constant thickness).
The only solution I see is to use the 3D Mesh Generation with sharp feature preservation and no criteria on the cells. You will have to provide the intersection of the bounding sphere with the surface yourself.
There is one example with two intersecting spheres in the user manual.

Objective C / Solving math systems

I've been trying to develop a simple app that calculates the equation of a curve using information given by the user.
For example, let's suppose the user has the equation of a circle and the equation of an ellipse, and he wants to know the intersection points.
Mathematically speaking, this is a quite simple problem, but i can't figure out how to tell Xcode to solve that system.
I've looked into the Accelerate framework, and i found the "dgesv" function of Lapack. This would be a perfect solution for a system of lines, but what about more complex systems like the one i've stated before?
I was even wondering how to calculate the tangent line of a curve, and other similar geometry problems.
For example, let's suppose the user has the equation of a circle and the equation of an ellipse, and he wants to know the intersection points. Mathematically speaking, this is a quite simple problem, but i can't figure out how to tell Xcode to solve that system.
The problem of intersecting a circle and an ellipse in general involves solving a fourth degree polynomial equation. You can break it down to third degree, but square roots alone won't suffice. So I'd say that's not really a “quiet simple problem”. That being said, some numeric libraries do support algorithms for finding the real or complex roots of a univariate polynomial. So you'd eliminate one of your variables (e.g. using resultants or Gröbner bases) and then feed the resulting polynomial to that. Not sure what libraries would be most suitable in the Objective C world. But a question asking to suggest a specific library would be deemed off-topic anyway, so use the keywords I mentioned to find something that suites your needs.
I was even wondering how to calculate the tangent line of a curve, and other similar geometry problems.
The tangent direction is simply orthogonal to the gradient of the implicit form. In other words, describe your curve not parametrically as x=f(t) and y=g(t) but instead implicitely as f(x,y)=0. In case of a circle that would look like x2+y2+ax+by+c=0. Then compute the partial derivatives with respect to x and y. That's 2x+a and 2y+b. So (2x+a, 2y+b) is perpendicular to the circle, and (2y+b, -2x-a) is tangential. Not sure what you'd consider similar to this.

how to compare the similarity of two 2D bezier curves

I am not familiar with bezier curves, but I need to compare two bezier curves for my project. A quick idea come up in my mind is to sample the two curves and then compare the sampled polylines using something like laplacian coordinates. This way I am comparing the points on the curve, which makes sense. But then I need to worry about the sampling rate. Another idea is to compare the control points of the bezier curves, however I am not sure if it makes sense to do so. Does anyone have experience on doing comparison between bezier curves?
Thanks in advance!

How to generate isolines (contour lines) at specific values from irregular data?

I have an array of sample points with their (X, Y, Z) coordinates. I use Delaunay Triangulation to generate an irregular network from them and then I use linear interpolation to plot contour lines at fixed values (e.g. 90, 95, 100, 105). The problem is that I need smooth contour lines to be generated with another algorithm. I've searched for some time now and found out that I need to use something like Kriging but I'm not that good at math to implement the algorithm from pure mathematical relations. Also I can't seem to find an implementation or explanation of the algorithm anywhere. Can anyone help me find one? Also, am I right with the chosen algorithm? Is there another one that can be easier to implement? Note that I don't care about precision.
https://dl.dropbox.com/u/15926260/ex.png
P.S. I've done a plot in Surfer showing the results that I'm looking for. On the right side is what I have done using triangulation and linear interpolation and on the left side is what I need to plot using a different algorithm (Kriging was used in Surfer).
Sorry for the spelling mistakes but I'm not a native language speaker.
Thank you!
You can try a regular (weighted) delaunay triangulation. In weighted delaunay triangulation triangle areas are more equal. IMO the kriging algorithm seems also to produce more equally contours. Weighted delaunay triangulation is also used to make smoother meshes.