computational-geometry

shortest paths & geodesics

十年热恋 提交于 2019-11-30 03:46:59
given a mesh made entirely of quads, where every vertex has valence n (with n >= 3), and does not lie on the same plane, I need to find the distance of every vertex in the mesh from a closed set of seed vertices. That is, given one or more mesh vertices (a seed set), I need to build a distance map that stores the distance of each mesh vertex from the seed set (which will have distance 0 from themselves). after spending some time searching for possible solutions, I got the following picture: 1) it is not trivial, and different approaches have been developed during the last 20 years or so 2)

Efficient Line Smoothing and/or Simplification

廉价感情. 提交于 2019-11-30 02:31:25
I am creating a painting application in Actionscript (although my question is not Actionscript related). The basic idea is to start painting when the mouse is pressed and tracking the mouse movements. What I want to achieve is: reduce mouse "noise" and create more smoother looking lines. Right now, ( 1 ) is problematic because I get thousands of mouse movements within a few seconds. Due to ( 1 ) the line can look jaggy. What current idea: when the user finishes drawing the line, I store all movements in an array and reduce them (median threshold) and then use a spline algorithm to recreate a

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

≯℡__Kan透↙ 提交于 2019-11-30 02:14:33
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 or Adobe Illustrator) that can be called using some sort of API or scripted to do boolean 2D paths

Intersection of N rectangles

荒凉一梦 提交于 2019-11-30 02:04:28
I'm looking for an algorithm to solve this problem: Given N rectangles on the Cartesian coordinate, find out if the intersection of those rectangles is empty or not. Each rectangle can lie in any direction (not necessary to have its edges parallel to Ox and Oy) Do you have any suggestion to solve this problem? :) I can think of testing the intersection of each rectangle pair. However, it's O(N*N) and quite slow :( Observation 1: given a polygon A and a rectangle B, the intersection A ∩ B can be computed by 4 intersection with half-planes corresponding to each edge of B. Observation 2: cutting

How to find out Geometric Median

我是研究僧i 提交于 2019-11-30 00:37:41
The question is: Given N points(in 2D) with x and y coordinates, find a point P (in N given points) such that the sum of distances from other(N-1) points to P is minimum. This point is commonly known as Geometric Median . Is there any efficient algorithm to solve this problem, other than the naive O(N^2) one? I solved something similar for a local online judge once using simulated annealing . That was the official solution as well and the program got AC. The only difference was that the point I had to find did not have to be part of the N given points. This was my C++ code, and N could be as

Maximum possible number of rectangles that can be crossed with a single straight line

守給你的承諾、 提交于 2019-11-29 22:56:07
I found this challenge problem which states the following : Suppose that there are n rectangles on the XY plane. Write a program to calculate the maximum possible number of rectangles that can be crossed with a single straight line drawn on this plane. I have been brainstorming for quite a time but couldn't find any solution. Maybe at some stage, we use dynamic programming steps but couldn't figure out how to start. Here is a sketch of an O(n^2 log n) solution. First, the preliminaries shared with other answers. When we have a line passing through some rectangles, we can translate it to any of

Expand fill of convex polygon

一世执手 提交于 2019-11-29 22:36:15
I have a convex polygon P1 of N points. This polygon could be any shape or proportion (as long as it is still convex). I need to compute another polygon P2 using the original polygons geometry, but "expanded" by a given number of units. What might the algorithm be for expanding a convex polygon? Oren Trutner To expand a convex polygon, draw a line parallel to each edge and the given number of units away. Then use the intersection points of the new lines as the vertices of the expanded polygon. The javascript/canvas at the end follows this functional breakdown: Step 1: Figure out which side is

Simplified (or smooth) polygons that contain the original detailed polygon

耗尽温柔 提交于 2019-11-29 21:02:59
I have a detailed 2D polygon (representing a geographic area) that is defined by a very large set of vertices. I'm looking for an algorithm that will simplify and smooth the polygon, (reducing the number of vertices) with the constraint that the area of the resulting polygon must contain all the vertices of the detailed polygon. For context, here's an example of the edge of one complex polygon: My research: I found the Ramer–Douglas–Peucker algorithm which will reduce the number of vertices - but the resulting polygon will not contain all of the original polygon's vertices. See this article

Nesting maximum amount of shapes on a surface

倖福魔咒の 提交于 2019-11-29 20:44:09
In industry, there is often a problem where you need to calculate the most efficient use of material, be it fabric, wood, metal etc. So the starting point is X amount of shapes of given dimensions, made out of polygons and/or curved lines, and target is another polygon of given dimensions. I assume many of the current CAM suites implement this, but having no experience using them or of their internals, what kind of computational algorithm is used to find the most efficient use of space? Can someone point me to a book or other reference that discusses this topic? After Andrew in his answer

Check If there exists a Circle

折月煮酒 提交于 2019-11-29 20:19:55
I was asked this during a Google Interview. We are given a string consisting of letters- F,L,R. - which is the instruction a robot follows F- goes forward by one step. L-turn left. R- turn right. String length can be upto 2500 characters. The string runs itself infinite times. We need to tell if there exists a circle with a radius, r( r can be any real number), such that the robot never leaves the circle. I was stuck at this point.I thought of using convex hull, but how to check it for infinite times.Explanation with code will be appreciated. Please help. Thanks in advance Each run(one run is