computational-geometry

What's the opposite of polygon triangulation?

狂风中的少年 提交于 2019-12-02 01:08:15
After I've done a 2D triangulation, some triangles have the same color and I want to recombine them for drawing into like-colored graphics paths. I find that if I just draw the triangles one by one, some graphic renderers shows seams between the triangles (at least if anti-aliasing and/or transparency is involved). So how do I take a set of (non-overlapping) triangles and produce a graphics path, which may contain holes and disjoint polygons? Blindly adding the triangles to a graphics path actually works pretty well for filling (though not for stroking, of course), but it doesn't feel right to

Show that, given a query point q, it can be tested in time O(log n) whether q lies inside P

爱⌒轻易说出口 提交于 2019-12-02 00:22:40
I am trying to solve some exercises of the book "Computational Geometry Algorithm and Applications, 3rd - de berg et al" of chapter 6 - Point Location. Unfortunately, I have no idea how to solve the following exercise: Given a convex polygon P as an array of its n vertices in sorted order along the boundary. Show that, given a query point q, it can be tested in time O(log n) whether q lies inside P. My Idea so far: The only way I know to determine if a point lies inside p in O(log n) is to use a directed acyclic graph. In order to use a directed acyclic graph I need to build it, which is

Extending a line segment to fit into a bounding box

浪子不回头ぞ 提交于 2019-12-01 17:27:17
I have a line segment defined by two pointF s, along with a 2D bounding rectangle. I want to extend the line segment as much as possible in both directions so that the segment is flush with the walls of the bounding box. Here are some examples of what I'm trying to do: Does anyone have any suggestions on how to do this? Here is an code example in python: def extend(xmin, ymin, xmax, ymax, x1, y1, x2, y2): if y1 == y2: return (xmin, y1, xmax, y1) if x1 == x2: return (x1, ymin, x1, ymax) # based on (y - y1) / (x - x1) == (y2 - y1) / (x2 - x1) # => (y - y1) * (x2 - x1) == (y2 - y1) * (x - x1) y

Can anyone recommend a good c++ convex hull shape/area library? [closed]

五迷三道 提交于 2019-12-01 16:41:51
I've been using boost::geometry , but it's still a young project and has a few too many bugs at the moment. Doubtless these will be fixed one day but is there a better choice right now? EDIT: the bugs that were troubling me are now fixed - back on boost::geometry. 来源: https://stackoverflow.com/questions/8990492/can-anyone-recommend-a-good-c-convex-hull-shape-area-library

Can anyone recommend a good c++ convex hull shape/area library? [closed]

我的未来我决定 提交于 2019-12-01 16:05:36
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I've been using boost::geometry , but it's still a young project and has a few too many bugs at the moment. Doubtless these will be

Query points on the vertices of a Hamming cube

孤街浪徒 提交于 2019-12-01 14:02:16
I have N points that lie only on the vertices of a cube, of dimension D, where D is something like 3. A vertex may not contain any point. So every point has coordinates in {0, 1} D . I am only interested in query time , as long as the memory cost is reasonable ( not exponential in N for example :) ). Given a query that lies on one of the cube's vertices and an input parameter r , find all the vertices (thus points) that have hamming distance <= r with the query. What's the way to go in a c++ environment? I am thinking of a kd-tree, but I am not sure and want help, any input, even approximative

How to solve nearest neighbor through the R-nearest neighbor?

一个人想着一个人 提交于 2019-12-01 12:02:56
问题 Citing the E2LSH manual ( it's not important that's about this specific library, this quote should be true for NN problem in general ): E 2LSH can be also used to solve the nearest neighbor problem, where, given the query q, the data structure is required the report the point in P that is closest to q. This can be done by creating several R-near neighbor data structures, for R = R1, R2, . . . Rt , where Rt should be greater than the maximum distance from any query point to its nearest

How to solve nearest neighbor through the R-nearest neighbor?

瘦欲@ 提交于 2019-12-01 12:01:34
Citing the E2LSH manual ( it's not important that's about this specific library, this quote should be true for NN problem in general ): E 2LSH can be also used to solve the nearest neighbor problem, where, given the query q, the data structure is required the report the point in P that is closest to q. This can be done by creating several R-near neighbor data structures, for R = R1, R2, . . . Rt , where Rt should be greater than the maximum distance from any query point to its nearest neighbor. The nearest neighbor can be then recovered by querying the data structures in the increasing order

Generating outside supporters into mesh for 3D printing

烂漫一生 提交于 2019-12-01 11:48:44
Prologue This is my attempt to re-ask the closed Generating supporters for 3D printing as it is interesting question but lacking important details ... This is intended as Q&A and currently I am working on the code for the answer but feel free to answer (I accept the best answer). Problem description OK here some basic info about the problem: Supports in 3D Printing: A technology overview As this is a huge problem I will focus on the generic mesh/support-pattern merging geometry problem. In a nutshell If we want to print any mesh we can do it only if it is connected to the starting plane up to

Confusion on Delaunay Triangulation and Largest inscribed circle

流过昼夜 提交于 2019-12-01 11:01:20
I need to find a largest inscribed circle of a convex polygon, I've searched many sites and I get that this can be done by using Delaunay triangulation. I found a thread in CGAL discussion with an algorithm using CGAL: You can compute this easily with CGAL: First, compute the Delaunay triangulation of the points. Then, iterate on all the finite faces of the triangulation. For each finite face f compute its circumcenter c locate c in the triangulation (to speed up things, you can give one vertex of f as starting hint for the point location) if the face returned by locate(c,hint) is finite, then