computational-geometry

Algorithm to compute set of bins bounded by a discrete contour

北战南征 提交于 2019-12-13 05:24:50
问题 On a discrete grid-based plane (think: pixels of an image), I have a closed contour that can be expressed either by: a set of 2D points (x1,y1);(x2,y2);(x3,y3);... or a 4-connected Freeman code, with a starting point: (x1,y1) + 00001112... I know how to switch from one to the other of these representations. This will be the input data. I want to get the set of grid coordinates that are bounded by the contour. Consider this example, where the red coordinates are the contour, and the gray one

How to rotate a line based on a given number of degrees

纵饮孤独 提交于 2019-12-13 02:15:20
问题 I have a line drawn with a Graphics object. I want to rotate this line a certain amount of degrees based on how much the mouse is dragged. I can get the number of degrees i need to rotate it but how do i then rotate the line based on that? Thank You! 回答1: You can create a Line2D object for your original line. Then you can use AffineTransform#getRotateInstance to obtain an AffineTransform that does the rotation about a certain angle, around a certain point. Using this AffineTransform , you can

Fast hiding of intersecting rectangles

老子叫甜甜 提交于 2019-12-12 22:16:43
问题 I'm working on an efficient algorithm to "hide" all the pairs of intersecting rectangles laid out in 2D in a set of N rectangles (axis aligned). All the rectangles have the same width and height. Suppose my starting set of rectangles laid out in 2D is R={r_1,r_2,...,r_n} where r_i are all the rectangles, r_i has the boolean attribute visible . I want to find the subset S of R such that for every r_i , r_j belonging to S r_i,_r_j don't intersect. A first trivial solution is the brute force

Furthest-point Voronoi diagram in Java

。_饼干妹妹 提交于 2019-12-12 17:09:05
问题 I'm looking for a naive algorithm to find the furthest point Voronoi diagram. Input sizes are not going to be big enough where I need something complex and as there are no Java libraries that I can find. I was hoping someone could describe a simple algorithm that shouldn't be too hard to compute? Thanks 回答1: You can find an algorithm pseduocode for farthest-point Voronoi diagram here. The Java code written by the same person is here. 回答2: I know this is kind of a late addition, but you might

Find overlapping circles

心已入冬 提交于 2019-12-12 11:24:45
问题 I have a rectangular area where there are circles with equal radius. I want to find which circles overlap with other circles (the output is a list of 2-element sets of overlapping circles). I know how to check if two of the circles overlap (the distance between their centers is less than the diameter). I can perform this check for every pair of circles, but I was wondering if there is a better algorithm (faster than O(n^2) ). EDIT The number of circles is usually about 100 and overlappings

Having the final Thiessen polygons, is it possible to find the initial set of points?

旧城冷巷雨未停 提交于 2019-12-12 10:23:18
问题 I'm trying to find a way to reverse the Voronoi algorithm. Basically, having some connected shapes which mostly consist of triangles and squares, I'm trying to find the set of points which, by using the Voronoi algorithm would recreate the initial shapes. 回答1: Introduction. This problem has been solved in a paper by Biedl et al. in 2013 after a partial solution by Ash and Boker in 1985. In case your Voronoi nodes are all of odd degree then the algorithm by Ash and Bolker works for you. First

Projecting a 3D point to a 2D screen position issue

送分小仙女□ 提交于 2019-12-12 10:18:45
问题 I have tried 4 methods, all which didn't work. Everywhere else my code works, the camera moves properly and the objects move properly. I am using SharpDX and my projection matrix is a perspective projection matrix. I am trying to get the screen position of a 3d point in order to position the cursor at that point. These are the 4 methods I have tried: public Vector2 WorldPosToScreenPos1(Vector3 p) { Vector3.Transform(ref p, ref View, out p); Vector3.Transform(ref p, ref Projection, out p);

A programming challenge with Mathematica

笑着哭i 提交于 2019-12-12 10:14:39
问题 I am interfacing an external program with Mathematica. I am creating an input file for the external program. Its about converting geometry data from a Mathematica generated graphics into a predefined format. Here is an example Geometry. Figure 1 The geometry can be described in many ways in Mathematica. One laborious way is the following. dat={{1.,-1.,0.},{0.,-1.,0.5},{0.,-1.,-0.5},{1.,-0.3333,0.},{0.,-0.3333,0.5}, {0.,-0.3333,-0.5},{1.,0.3333,0.},{0.,0.3333,0.5},{0.,0.3333,-0.5},{1.,1.,0.},

Java library for creating straight skeleton?

浪尽此生 提交于 2019-12-12 08:48:00
问题 I have as an input a 2D polygon with holes, and I need to find it's straight skeleton, like in the picture: (source: cgal.org) Maybe there is a good Java library for it? And if not, can you point me to the good explanation of the algorithm, so I could implement it myself? (I haven't found good resources on Google) 回答1: I wrote this a little while back. Not sure if it's robust enough. https://github.com/twak/campskeleton (edited for 2018...) 回答2: See http://www.sable.mcgill.ca/~dbelan2/roofs

Distance from reference line at right angle

浪尽此生 提交于 2019-12-12 07:05:22
问题 A few weeks back I received a script that, I think, calculates the distance of a point from a reference line (at right angle) and returns the distance along the reference line as well as the distance from the reference line to that point. To be honest, this is what I think it does, however I do not fully understand the script even though it is only 26 lines long. Since I think the script is the problem why another script, which depends on it, gets unstable I figured it is actually handy to