computational-geometry

Smallest enclosing circle in Python, error in the code

拥有回忆 提交于 2019-12-03 23:35:22
I have a set of points that represent the vertices (x, y) of a polygon. points= [(421640.3639270504, 4596366.353552659), (421635.79361391126, 4596369.054192241), (421632.6774913164, 4596371.131607305), (421629.14588570886, 4596374.870954419), (421625.6142801013, 4596377.779335507), (421624.99105558236, 4596382.14190714), (421630.1845932406, 4596388.062540068), (421633.3007158355, 4596388.270281575), (421637.87102897465, 4596391.8018871825), (421642.4413421138, 4596394.918009778), (421646.5961722403, 4596399.903805929), (421649.71229483513, 4596403.850894549), (421653.8940752105, 4596409

Boolean operations on a SVG pathstring

邮差的信 提交于 2019-12-03 21:14:13
问题 I've come to a conceptually difficult problem. In short, I need to find the vector path of two vector paths combined through different boolean operations. Such as the Union, the Difference, the Intersection, and Subtraction. It would be nice if I could do it similar to how Canvas does it's globalCompositeOperation. How in the world would I go about doing this? 回答1: There is a JavaScript library that allows for boolean operations on SVG paths under the condition that the path is a polygon.

Computing face normals and winding

≯℡__Kan透↙ 提交于 2019-12-03 17:46:03
Given a convex polyhedron with defined vertices (x, y, z) that specifies the faces of the polyhedron. How can I go about calculating the surface normal of each face of the polyhedron? I need the surface normal in order to compute the vertex normal to perform Gouraud shading . The only clue I could find about how to do this is Newell's method, but how do I make sure the normals are outward normals and not inward? Thanks for any help. Compute the face normal You have to compute the cross product of two vectors spanning the plane that contains the given face. It gives you the (non-unit) normal

Merging and splitting overlapping rectangles to produce non-overlapping ones

我只是一个虾纸丫 提交于 2019-12-03 17:20:37
I am looking for an algorithm as follows: Given a set of possibly overlapping rectangles (All of which are "not rotated", can be uniformly represented as (left,top,right,bottom) tuplets, etc...), it returns a minimal set of (non-rotated) non-overlapping rectangles, that occupy the same area. It seems simple enough at first glance, but prooves to be tricky (at least to be done efficiently). Are there some known methods for this/ideas/pointers? Methods for not necessarily minimal, but heuristicly small, sets, are interesting as well, so are methods that produce any valid output set at all.

Find the perimeter of a subset of a near-regular grid of points

风格不统一 提交于 2019-12-03 16:34:55
Let us consider a set of near-regular grids in 2-D. These grids are adjacent (neighbouring grids have one or more same vertices) to the neighbouring grids. Here are the sample of 10 grids with the coordinates of the vertices (longitude,latitude) are as follows A<- lon lat [,1] [,2] [1,] 85.30754 27.91250 [2,] 85.32862 27.95735 [3,] 85.34622 27.89880 [4,] 85.36732 27.94364 [5,] 85.34958 28.00202 [6,] 85.38831 27.98830 [7,] 85.38487 27.88508 [8,] 85.40598 27.92991 [9,] 85.42353 27.87134 [10,] 85.44466 27.91616 [11,] 85.42698 27.97456 [12,] 85.46567 27.96081 [13,] 85.48334 27.90239 [14,] 85.50437

The minimum perimeter convex hull of a subset of a point set

ⅰ亾dé卋堺 提交于 2019-12-03 15:41:35
问题 Given n points on the plane. No 3 are collinear. Given the number k. Find the subset of k points, such that the convex hull of the k points has minimum perimeter out of any convex hull of a subset of k points. I can think of a naive method runs in O(n^k k log k). (Find the convex hull of every subset of size k and output the minimum). I think this is a NP problem, but I can't find anything suitable for reduction to. Anyone have ideas on this problem? An example, the set of n=4 points {(0,0),

Algorithm for finding the segment overlapping two collinear segments

与世无争的帅哥 提交于 2019-12-03 14:12:27
UPDATES My original implementation in C# My final implementation in C#, based on the answers I got. Given the following conditions, how can I programatically find the overlapping segment between two lines? Also, for a different slope: And for vertical lines: And for horizontal lines: Note: For all the quadrants ! I've started by coding all possible conditions but it gets ugly. public Line GetOverlap (Line line1, Line line2) { double line1X1 = line1.X1; double line1Y1 = line1.Y1; double line1X2 = line1.X2; double line1Y2 = line1.Y2; double line2X1 = line2.X1; double line2Y1 = line2.Y1; double

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

老子叫甜甜 提交于 2019-12-03 13:56: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 because it matches the list of points. I am looking for a fast way (quicker than linear) to check for

Best dynamic data structure for 2d circle nearest neighbor

折月煮酒 提交于 2019-12-03 13:22:29
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 in arbitrary order must be supported. Nothing is known about the set's geometric distribution in

Given a vector of points (possibly out of order), find polygon (not convex hull)

一曲冷凌霜 提交于 2019-12-03 13:01:19
I currently have a vector of points vector<Point> corners; where I have previously stored the corner points of a given polygon. Given that, I know for sure that the points form a simple polygon that does not contain any self-intersecting edges. However, in the process of storing these vertices, the order in which they connect to each other was not preserved. I now have a function that, given a vector of points, connects them and draws me a closed figure. However, I need to give this function the sequence of points in the order they need to be connected. Can anyone suggest a way that I could