computational-geometry

find the smallest containing convex polygon with a given number of points

别说谁变了你拦得住时间么 提交于 2019-11-29 05:54:37
问题 given a convex polgyon and a number N, how do I find the smallest polygon that contains every point from the original polygon has exactly N corner points For example, suppose I have a set of points and compute the convex hull for them (green). Now I want to find the smallest quadrangle that contains all the points (red) It is easy to see that any other polygon with 4 corners would either be bigger or fail to contain all the points. But how do I find this polygon in the general case? EDIT:

Computational complexity and shape nesting

我与影子孤独终老i 提交于 2019-11-29 04:28:45
I have SVG abirtrary paths which i need to pack as efficiently as possible within a given rectangle(as less waste of space as possible). After some research i found the bin packing algorithms which seems to be dealing with boxes and not curved random shapes(my SVG shapes are quite complex and include beziers etc.). AFAIK, there is no deterministic algorithm for actually packing abstract shapes. I wish to be proven wrong here which would be ideal(having a mathematical deterministic method for packing them). In case I am right however and there is not, what would be the best approach to this

Java - Draw a ruler (line with tick marks at 90 degree angle)

故事扮演 提交于 2019-11-29 04:27:01
I'm using Java AWT to draw lines on a panel ( Line2D and Graphics2D.drawLine() ) and I'm wondering how I can draw a line with tick marks, similar to: |----|----|----|----|----| I know the positions I'd like to draw the ticks at in advance. The lines could be in any position, so the ticks must be drawn at an angle releative to the line itself. My basic geometry & ability to apply it in Java is failing me. :) I suggest you implement a ruler-drawing-method that draws a simple horizontal ruler from left to right Figure out the desired angle using Math.atan2 . Apply an AffineTransform with

find overlapping rectangles algorithm

谁都会走 提交于 2019-11-29 03:54:57
let's say I have a huge set of non-overlapping rectangle with integer coordinates, who are fixed once and for all I have another rectangle A with integer coordinates whose coordinates are moving (but you can assume that its size is constant) What is the most efficient way to find which rectangles are intersecting (or inside) A? I cannot simply loop through my set as it is too big. Thanks edit : the rectangles are all parallel to the axis Personally, I would solve this with a KD-Tree or a BIH-Tree. They are both adaptive spatial data structures that have a log(n) search time. I have an

Algorithm for path simplification and smoothing of 2D trajectories

混江龙づ霸主 提交于 2019-11-29 01:49:29
问题 I'm searching for an algorithm for path simplification and smoothing for 2D trajectories. So I have a ordered list of 2D points. These points should be simplified, e.g. with the Ramer–Douglas–Peucker algorithm. But the output must be smooth, so the resulting path should be constructed from Bezier curves or splines. Is there any modification of the Ramer–Douglas–Peucker algorithm which could handle this? I found a path simplification algorithm in the paper.js library, which does exactly what I

Nearest Neighbor Searching using Voronoi Diagrams

╄→尐↘猪︶ㄣ 提交于 2019-11-29 01:47:46
I've successfully implemented a way to generate Voronoi diagrams in 2 dimensions using Fortune's method. But now I'm trying to use it for nearest neighbor queries for a point (which is not one of the original points used to generate the diagram). I keep seeing people saying that it can be done in O(lg n) time (and I believe them), but I can't find a description of how it's actually done. I'm familiar with binary searches, but I can't figure out a good criteria to guarantee that upper bound. I also figured maybe it could have to do with inserting the point into the diagram and updating

random unit vector in multi-dimensional space

六月ゝ 毕业季﹏ 提交于 2019-11-29 01:16:19
I'm working on a data mining algorithm where i want to pick a random direction from a particular point in the feature space. If I pick a random number for each of the n dimensions from [-1,1] and then normalize the vector to a length of 1 will I get an even distribution across all possible directions? I'm speaking only theoretically here since computer generated random numbers are not actually random. Bram Cohen One simple trick is to select each dimension from a gaussian distribution, then normalize: from random import gauss def make_rand_vector(dims): vec = [gauss(0, 1) for i in range(dims)]

SVG / vector graphical objects boolean operations (union, intersection, subtraction)

眉间皱痕 提交于 2019-11-28 23:09:17
问题 I have 2D closed vector paths, specified in SVG paths-like syntax - i.e. these paths include straight lines and various Bezier curves. Is there anything like a small, nice & discrete library (preferably in C, Java or Ruby, but any language will do if this library is clean and easy to use) that allows to do boolean operations like union, intersection and subtraction with these paths? What I've found so far includes: Huge and pricey commercial vector graphic products (such as Autodesk AutoCAD

Mesh to mesh intersections

谁说胖子不能爱 提交于 2019-11-28 21:36:49
I'm looking for a library or a paper that describes how to determine if one triangular mesh intersects another. Interestingly I am coming up empty. If there is some way to do it in CGAL, it is eluding me. It seems like it clearly should be possible, because triangle intersection is possible and because each mesh contains a finite number of triangles. But I assume there must be a better way to do it than the obvious O(n*m) approach where one mesh has n triangles and the other has m triangles. The way we usually do it using CGAL is with CGAL::box_intersection_d . You can make it by mixing this

How to determine if a Delaunay triangle is internal or external?

≡放荡痞女 提交于 2019-11-28 21:35:55
问题 I am writing a program that requires a implementation of Medial Axis extraction, of which Delaunay triangulation is a step. External medial axis is unwanted so the corresponding external triangles are intended to be removed. Luckily I came upon a page with a lot of diagrams, also a hint of a method to determine internal and external Delaunay triangles ("based on the broken line perimeter"), but it's just a hint, without detailed explanation. Anybody know the algorithm? EDIT: I forgot