computational-geometry

How to find if a point is within a set of intervals?

岁酱吖の 提交于 2019-12-21 04:26:05
问题 I am looking for the fastest way to decide whether or not a point on a line is within a subset of this line. I am given an integer Point, and I also have a "list" of either: Points, represented by an integer ( 3, 10, 1000, etc) Intervals, that I represent by 2 integers ( 2:10 is all integers from 2 to 10 inluded, 50:60, etc) In this example, if the value of my point is 5, then I return true because it is included in an interval, same for 55. If my point is equal to 1000, I also return true

How to fastest check if point (3D) is inside convex hull given by set of point

心不动则不痛 提交于 2019-12-21 04:25:43
问题 I have set P of point (3D) which are vertices of convex hull (every one). I looking for method for checking if given point p0 is NOT outside of this convex hull. I'll have to repeat the checking it several times (for different p0). So if is possible to reuse part of computation it would be great. On stackoverflow pages i found this: Find if a point is inside a convex hull for a set of points without computing the hull itself There are 2 aproche: First based on convex hull property - set of

Best dynamic data structure for 2d circle nearest neighbor

喜你入骨 提交于 2019-12-21 04:12:09
问题 The title is most of the problem. I have a set of circles, each given by a center C and radius r. The distance between two circles is the Euclidean distance between their centers minus both their radii. For circles a and b, d_ab = |C_a - C_b| - r_a - r_b. Note this can be negative if the circles overlap. Then what is the quickest data structure for finding the nearest (minimum distance) neighbor of a given circle in the set? Adding and deleting circles with "find nearest" queries interleaved

n-th order Bezier Curves?

穿精又带淫゛_ 提交于 2019-12-21 03:37:26
问题 I've managed to implement quadratic and cubic Bezier curves.They are pretty straightforward since we have a formula. Now I want to represent an n-th order Bezier curve using the generalization: Where and I'm using a bitmap library to render the output, so here is my code: // binomialCoef(n, k) = (factorial(n) / (factorial(k) * factorial(n- k))) unsigned int binomialCoef(unsigned int n, const unsigned int k) { unsigned int r = 1; if(k > n) return 0; for(unsigned int d = 1; d <= k; d++) { r *=

Determining ordering of vertices to form a quadrilateral

孤者浪人 提交于 2019-12-21 02:56:29
问题 Suppose I have 4 vertices in 2D space. Does anything know of an efficient algorithm which will give me an ordering of the vertices which corresponds to a simple quadrilateral? That is, it will label the vertices 1, 2, 3, 4 so that if I follow 1-2, 2-3, 3-4 I will have traced a simple (i.e. non-intersecting) quadrilateral. Just providing the name of a standard algorithm which I can google would be fine. 回答1: You may be interested in methods of convex hull computing, such as Graham scan. 回答2:

Local maxima in a point cloud

旧巷老猫 提交于 2019-12-21 02:56:12
问题 I have a point cloud C, where each point has an associated value. Lets say the points are in 2-d space, so each point can be represented with the triplet (x, y, v). I'd like to find the subset of points which are local maxima. That is, for some radius R, I would like to find the subset of points S in C such that for any point Pi (with value vi) in S, there is no point Pj in C within R distance of Pi whose value vj is greater that vi. I see how I could do this in O(N^2) time, but that seems

Find the Closest intersection point in plan

廉价感情. 提交于 2019-12-21 02:26:09
问题 I was asked following question in interview recently: Let suppose you have, following grid on Cartesian coordinate system ( Quadrant I). o - x - x - x - o | | | | | x - x - x - o - x | | | | | x - o - o - x - x where, o => person at intersection and x => no person at intersection class Point { int x; int y; boolean hasPerson; } Point findNearestPointWhereAllPeopleCanMeet(Point[] people) { } Implement a routine where given a list of people location (points), find a location(point) such that is

How to compute the union polygon of two (or more) rectangles

时光毁灭记忆、已成空白 提交于 2019-12-21 02:20:24
问题 For example we have two rectangles and they overlap. I want to get the exact range of the union of them. What is a good way to compute this? These are the two overlapping rectangles. Suppose the cords of vertices are all known: How can I compute the cords of the vertices of their union polygon? And what if I have more than two rectangles? 回答1: There exists a Line Sweep Algorithm to calculate area of union of n rectangles. Refer the link for details of the algorithm. As said in article, there

C++ 2D tessellation library?

a 夏天 提交于 2019-12-20 20:02:13
问题 I've got some convex polygons stored as an STL vector of points (more or less). I want to tessellate them really quickly, preferably into fairly evenly sized pieces, and with no "slivers". I'm going to use it to explode some objects into little pieces. Does anyone know of a nice library to tessellate polygons (partition them into a mesh of smaller convex polygons or triangles)? I've looked at a few I've found online already, but I can't even get them to compile. These academic type don't give

Finding a bounded rectangle inside a concave/convex polygon

心已入冬 提交于 2019-12-20 14:37:15
问题 I'm looking for a method for finding an axis-aligned rectangle inside a concave or convex polygon. I've been looking around the web, the closest solutions I could find would only fit a convex polygon, and not a concave one. For example - Finding an axis-aligned rectangle inside a polygon To be honest I'm not a great math wiz, so I would rather find code samples or a code library, but I guess I could handle some math by myself, or find someone to help me with it. It would be really nice if the